ankane / blazer

Business intelligence made simple
MIT License
4.5k stars 471 forks source link

Add basic JSON and YAML rendering in pre tag #389

Open cianmce opened 2 years ago

cianmce commented 2 years ago

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

jpaulomotta commented 1 year ago

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

cianmce commented 9 months ago

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