Json To Org-Mode Table
As part of the Emacs minor mode I'm working on I've created a useful function to turn json into Org tables while maintaining the linkage of nested structures. The is cleverly named json-to-org-table.
Why?
Json is a great format for programming and parsing structures but a less good language for human consumption. I created this tool so I could interact with APIs and have a human readable format (and one that exports nicely too!)
What's that look like?
Much of the tool is covered on the github README.md
. Here's an example of using it in org mode to build a set of linked tables
As JSON
curl -X GET "https://archive.org/wayback/available?url=noonker.github.io"
{
"archived_snapshots": {
"closest": {
"available": true,
"timestamp": "20201209030058",
"status": "200",
"url": "http://web.archive.org/web/20201209030058/https://noonker.github.io/"
}
},
"url": "noonker.github.io"
}
… and as linked tables
In an org buffer it would look like this:
#+name: requester #+begin_src bash :results drawer curl -X GET "https://archive.org/wayback/available?url=noonker.github.io" #+end_src #+RESULTS: :results: {"url": "noonker.github.io", "archived_snapshots": {"closest": {"url": "http://web.archive.org/web/20201209030058/https://noonker.github.io/", "status": "200", "timestamp": "20201209030058", "available": true}}} :end: #+name: to-json-table #+begin_src emacs-lisp :var str=requester() :results raw (json-to-org-table-parse-json-string str) #+end_src #+RESULTS: to-json-table | key | value | |--------------------+--------------------| | archived_snapshots | [[archived_snapshots]] | | url | noonker.github.io | #+name: archived_snapshots | key | value | |---------+----------------------------| | closest | [[closest_archived_snapshots]] | #+name: closest_archived_snapshots | key | value | |-----------+----------------------------------------------------------------------| | timestamp | 20201209030058 | | available | t | | status | 200 | | url | http://web.archive.org/web/20201209030058/https://noonker.github.io/ |
Bugs
I'm sure there are bugs- Open up a bug or PR in the repo.
Read other posts