blazer icon indicating copy to clipboard operation
blazer copied to clipboard

Add basic JSON and YAML rendering in pre tag

Open cianmce opened this issue 3 years ago • 2 comments

Following on from idea: https://github.com/ankane/blazer/issues/388

If a column name contains JSON or YAML then do the appropriate parsing and pretty-printing, if parsing fails then just return the value in a pre tag and highlight using hljs

We could also add config to explicitly enable or disable this, similar to what is done with image


Sample SQL using MySQL data source

SELECT
  'test: {"k2": "v2", "k3": {"k4": "v4"}}\ntest2: [1,2]' AS sample_yaml,
  '{"test":{"k2":"v2","k3":{"k4":"v4"}},"test2":[1,2]}' AS sample_json,
  'test_content' AS sample_text
UNION
SELECT 'invaid: yaml\nobject', '{"invalid": "json"', 'more_text'

image

cianmce avatar Feb 24 '22 10:02 cianmce

I think this is a great idea and it would be useful on projects that I'm working on.

jpaulomotta avatar Jul 21 '23 14:07 jpaulomotta

@ankane is this something you'd look at including?

cianmce avatar Nov 24 '23 11:11 cianmce