reddit / emacs
JSON visualization for Emacs?
timmli · 2022-11-22 17:20
There are tools like [JSON Crack](https://jsoncrack.com/editor) (also available for VS Code) that visualize the structure of a JSON file.
https://preview.redd.it/ydc2eq9kcj1a1.png?width=2466&format=png&auto=webp&s=88190781f0915ebb1bf3a7ff2a2221ce9b20c65b
Is something like this also available in Emacs?
ckoneru · 2022-11-22 17:50
No, there is none to my knowledge.
00-11 · 2022-11-22 17:58
I'm curious. Do you really find that graphic visualization clearer than just the JSON itself? (I don't.)
itistheblurstoftimes · 2022-11-22 18:03
Yeah, maybe if you like to read JSON data for pleasure at night on your tablet. But I don't understand why someone who is programming something would ever want to see this.
anaumann · 2022-11-22 18:13
To some degree, it is easier to digest, because the amount of data in view is limited if you're going from one box to the next...
That said, it's nothing some folding wouldn't do equally well :)
​
Edit: And it reminds me of the time when I wrote a Python program that would visualise AWS Cloudwatch events on a timeline for easier post mortems... It was nice while I was testing, but with real-world data, gimp refused to open the PNG, because it would have taken 100GB of RAM to load the file :D
mitchTux · 2022-11-22 19:32
No but you could probably use this to expand and collapse objects https://github.com/gregsexton/origami.el
oburn42 · 2022-11-22 20:44
I use [PlantUML support for JSON](https://plantuml.com/json) along with [Org babel support for PlantUML](https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-plantuml.html) to generate visual diagrams. It actually works quite well.
timmli · 2022-11-22 22:00
Depends on the JSON file and the way it is visualized. If the structure is nested like in the above example, the wide screen could be better used and it seems easier to get a quick overview. Generally, visual representations like boxes and arrows are easier to digest in my view. Folding the code doesn't keep up with that.
Alles-Erlaubt · 2022-11-22 22:14
JSON navigator?
https://github.com/DamienCassou/json-navigator
deaddyfreddy · 2022-11-22 23:19
since most of the time I work in Clojure, I use Cider as a whatever-format-is inspection tool
AndreaSomePostfix · 2022-11-23 00:02
thanks I didn't know this existed!
JohnDoe365 · 2022-11-23 10:20
Breadcrumbs for LSP-mode may also be helpful. For eglot it's under consideration.
unhammer · 2022-11-23 13:19
got an example? tried
#+begin_src plantuml :file foo.jpg
@startjson
{ "foo":{"bar":0},"fie":"hi"}
@endjson
#+end_src
but got "No @startuml found"
WorldsEndless · 2022-11-24 15:19
I use Cider daily, too, but I'd love to know what you are talking about. Is there a nifty way to view json with it? For that matter, are there formatting/tree-nav features I don't know about for EDN?
deaddyfreddy · 2022-11-25 09:09
> Is there a nifty way to view json with it?
I just eval the json parsing expression and use something like cider-inspect-last-result. If I want to narrow the scope - there's always `get-in`/`nth`, etc.
oburn42 · 2022-11-28 23:49
Sorry for the delay - here is a sample of what I do - note that I use two source blocks, so that I can edit the JSON using the correct mode. The trick is to include the JSON block into the PlantUML block.
#+NAME: simple-json
#+BEGIN_SRC json
{
"example": {
"using": "yaml",
"nested": {
"object": true
}
}
}
#+END_SRC
#+BEGIN_SRC plantuml :noweb yes :file /tmp/example.png
@startjson
<<simple-json>>
@endjson
#+END_SRC
unhammer · 2022-11-29 10:28
Thanks, that's pretty much what I did, but still not getting it to work. Maybe it's just my plantuml Version: 1:1.2018.13+ds-2 that's too old