Live data from Hacker News

Json.human.js: Json Formatting for Human Beings

marianoguerra.github.io

21–30 of 71 posts

Re: Json.human.js: Json Formatting for Human Beings

#22

This is awesome. It's funny, I didn't think it would be useful until I actually checked it out, because I personally find JSON to be fairly readable.

yep, JSON is really readable when indented and colored, but if you need to display it to non technical people something more "tabular" may be a better solution.

that's the reason for this lib.

thanks for the awesome part :D

Re: Json.human.js: Json Formatting for Human Beings

#23

This reminds me of ColdFusion's cfdump: https://www.google.com/search?q=coldfusion+dump+object&tbm=i... http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0...

the world is a circle

I was looking this morning at a lib to do this and I couldn't find one, but at one stack overflow question someone posted a screenshot of the ColdFusion tool and I said "that's what I need" and then I decided to do it myself.

now someone mentions it here, full circle :D

Re: Json.human.js: Json Formatting for Human Beings

#26
Pretty funny considering JSON is self described as "easy for humans to read and write." If your target is nontechnical folks, I wonder if it would be useful to go a step further and:

- Remove quotes from strings. They're already formatted differently.

- Remove array indices.

- Unescape strings.

The context and formatting should still be enough for devs, but I can't imagine quotes or indices do anything for nontechnical people.

e.g. ["\"foo\"","bar"] translates to:

"foo"

bar

Re: Json.human.js: Json Formatting for Human Beings

#28

This is great! And nicely written--it would be very easy to modify this to format things differently. Eventually, it would be cool to have the conversion go both ways. That way it could be incorporated in a CMS (arbitrary structured content being passed around as JSON but displayed and edited in HTML).

since css classes tell you what's inside you can recover it completely, also I was thinking on using HTML5's data- to store the data there too. the next next step would be to provide in place edition with validation :)

the next next step would be to provide in place edition with validation :)

Definitely! Take a look at http://createjs.org/--it will probably help (in fact, I've been using it for a different project and if I have time I might be submitting a pull request to you in the next week or so).

Re: Json.human.js: Json Formatting for Human Beings

#29
post #26

Pretty funny considering JSON is self described as "easy for humans to read and write." If your target is nontechnical folks, I wonder if it would be useful to go a step further and: - Remove quotes from strings. They're already formatted differently. - Remove array indices. - Unescape strings. The context and formatting should still be enough for devs, but I can't imagine quotes or indices do anything for nontechnic…

about removing quotes from strings, I tought about it, and I think as long as some other display property is different (to differentiate the number 4 from the string "4") and something more than color to avoid causing trouble to colorblind people I think it's a good idea.

the array indices I was thinking on having it as an option, I would like 'something' to make them standout as lists even when no index is displayed, any idea?

will open issues for both:

* https://github.com/marianoguerra/json.human.js/issues/5

* https://github.com/marianoguerra/json.human.js/issues/6

Re: Json.human.js: Json Formatting for Human Beings

#30

author here: let me know if you have any questions

Great work! Would be nice to add an option to convert json key names to human-friendly names(passed as a separate key value array). So a key like full_name can appear as "Your Name:" to the end user.

It might be good enough (and less complicated) to just optionally prettify camelCased and underscore_separated field names (to "Camel Case" and "Underscore Separated", respectively).
Post reply on HN