Re:JSON Crack – Visualize JSON data into graphs
by coenhyde on Sunday August 28, 2022 @09:10AM
(#32628129)
If you climb to the top of a really tall mountain you'll get a similar perspective to what Google Maps provides.
Re:JSON Crack – Visualize JSON data into graphs
by abrax3141 on Sunday August 28, 2022 @11:27AM
(#32629128)
That’s not really fair. At the moment we communicate and read json in text, so formatting the text to be human-readable and reasonably arranged often (although not always) matters.
Re:JSON Crack – Visualize JSON data into graphs
by solardev on Sunday August 28, 2022 @11:12AM
(#32629008)
Ads?
Re:JSON Crack – Visualize JSON data into graphs
by btown on Sunday August 28, 2022 @12:37PM
(#32629714)
We prefer to call them contextually preferred mountaintop suggestions. To suggest otherwise would be to suggest that our entire industry is built on nothing more than peak comedy.
Re:JSON Crack – Visualize JSON data into graphs
by samstave on Sunday August 28, 2022 @02:12PM
(#32630570)
Peak comedy is a slippery slope. Just be careful to not trigger an avalanche of puns, because that can snowball into something unstoppable, then everything goes downhill fast!
Re:JSON Crack – Visualize JSON data into graphs
by helmholtz on Sunday August 28, 2022 @03:20PM
(#32631200)
High-brow humour is not HN's strong suit it would appear :)
Re:JSON Crack – Visualize JSON data into graphs
by ozim on Monday August 29, 2022 @12:33PM
(#32640187)
I actually laughed.
Though - one does not have to do that stuff manually I can imagine some json linter could be configured to do such layout, or someone can just write tool to do that. So idea for this indentation is not bad IMHO.
Re:JSON Crack – Visualize JSON data into graphs
by dotancohen on Monday August 29, 2022 @06:51AM
(#32636623)
Python formats it almost exactly like you did:
$ python3 -m json.tool
{
"squadName": "Super hero squad",
"homeTown": "Metro City",
"formed": 2016,
"secretBase": "Super tower",
"active": true,
"members": [
{
"name": "Molecule Man",
"age": 29,
"secretIdentity": "Dan Jukes",
"powers": [
"Radiation resistance",
"Turning tiny",
"Radiation blast"
]
},
{
"name": "Madame Uppercut",
"age": 39,
"secretIdentity": "Jane Wilson",
"powers": [
"Million tonne punch",
"Damage resistance",
"Superhuman reflexes"
]
},
{
"name": "Eternal Flame",
"age": 1000000,
"secretIdentity": "Unknown",
"powers": [
"Immortality",
"Heat Immunity",
"Inferno",
"Teleportation",
"Interdimensional travel"
]
}
]
}
Re:JSON Crack – Visualize JSON data into graphs
by geokon on Monday August 29, 2022 @07:32AM
(#32636904)
I don't python, but this scheme missed the point. Keys are vertically aligned, but values are not. Some brackets are vertically aligned, other are not (you have to hunt for the starting square brackets). Bracket take up a whole line each wasting vertical space.
Re:JSON Crack – Visualize JSON data into graphs
by dotancohen on Monday August 29, 2022 @07:35AM
(#32636937)
I see, thanks. For me, the point is just "indent successive objects" so it suffices - especially when I'm in a Python mindset and mentally filtering out brackets anyway. But I could understand why you prefer the formatting as you do.
Re:JSON Crack – Visualize JSON data into graphs
by geokon on Monday August 29, 2022 @09:07AM
(#32637716)
I think having the values aligned make it much quicker to read off entries. I will generally looked at the keys for the first entry, but for subsequent entries I assume the same ordering and just look at the values on the right.
It's a bit trivial, but another subtle effect that I like is that the sub-blocks are not mutually vertically aligned due to being offset by the semi-random length of the key
So for instance
{"squadName": "Super hero squad",
"homeTown": "Metro City",
"formed": 2016,
"secretBase": "Super tower",
"active": true,
"members": [{"name": "Molecule Man",
"age": 29,
"secretIdentity": "Dan Jukes",
"powers": ["Radiation resistance",
"Turning tiny",
"Radiation blast"]},
{"name": "Madame Uppercut",
"age": 39,
"secretIdentity": "Jane Wilson",
"powers": ["Million tonne punch",
"Damage resistance",
"Superhuman reflexes"]}],
"enemies": [{"name": "Eternal Flame",
"age": 1000000,
"secretIdentity": "Unknown",
"powers": ["Immortality",
"Heat Immunity",
"Inferno",
"Teleportation",
"Interdimensional travel"]}]}
at a glance you see that the third person is not part of the same list as the first twoIf all second level blocks are at the same level then you need to visually catch that there is extra key.
Re:JSON Crack – Visualize JSON data into graphs
by nerdponx on Sunday August 28, 2022 @04:02PM
(#32631552)
This is how Lisp code (and S-expressions in general) is conventionally indented.
Re:JSON Crack – Visualize JSON data into graphs
by sn9 on Thursday September 01, 2022 @12:41PM
(#32679034)
You can even do this by console logging with JSON.stringify(): https://stackoverflow.com/questions/4810841/pretty-print-jso...
Re:JSON Crack – Visualize JSON data into graphs
by bboozzoo on Sunday August 28, 2022 @08:27AM
(#32627865)
Have you tried json-mode? Seems to work pretty well.
Re:JSON Crack – Visualize JSON data into graphs
by geokon on Sunday August 28, 2022 @08:32AM
(#32627894)
The point was that the keys and values are all aligned to the same minimal column numbers :) Both `json-mode` `json-reformat` don't seem to do that (and ideally I'd like something that'd work with Clojure/EDN code..)
Re:JSON Crack – Visualize JSON data into graphs
by user5678 on Sunday August 28, 2022 @11:04AM
(#32628937)
gg=G in evil mode will do that.
Re:JSON Crack – Visualize JSON data into graphs
by dotancohen on Monday August 29, 2022 @07:39AM
(#32636970)
Evil (Emacs 27.1) produced this:
{
"squadName": "Super hero squad",
"homeTown": "Metro City",
"formed": 2016,
"secretBase": "Super tower",
"active": true,
"members": [
{
"name": "Molecule Man",
"age": 29,
"secretIdentity": "Dan Jukes",
"powers": [
"Radiation resistance",
"Turning tiny",
"Radiation blast"
]
},
{
"name": "Madame Uppercut",
"age": 39,
"secretIdentity": "Jane Wilson",
"powers": [
"Million tonne punch",
"Damage resistance",
"Superhuman reflexes"
]
},
{
"name": "Eternal Flame",
"age": 1000000,
"secretIdentity": "Unknown",
"powers": [
"Immortality",
"Heat Immunity",
"Inferno",
"Teleportation",
"Interdimensional travel"
]
}
]
}
Interestingly, the first-level items are not indented. Real VIM 8.1 produced the same format, but the first-level items _are_ indented.
PS: Does anyone knows if there was an emacs mode that'd do this for me automagically?