Skip to content

Add basic JSON and YAML rendering in pre tag - #389

Open
cianmce wants to merge 5 commits into
ankane:masterfrom
cianmce:render-yaml-and-json
Open

Add basic JSON and YAML rendering in pre tag#389
cianmce wants to merge 5 commits into
ankane:masterfrom
cianmce:render-yaml-and-json

Conversation

@cianmce

@cianmce cianmce commented Feb 24, 2022

Copy link
Copy Markdown
Contributor

Following on from idea: #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

Copy link
Copy Markdown

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

@cianmce

cianmce commented Nov 24, 2023

Copy link
Copy Markdown
Contributor Author

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

Comment thread app/helpers/blazer/base_helper.rb Outdated
Comment thread app/helpers/blazer/base_helper.rb Outdated
@sergeyk

sergeyk commented Mar 14, 2025

Copy link
Copy Markdown

This would be incredible!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants