Skip to main content
8 events
when toggle format what by license comment
Sep 26, 2022 at 13:45 comment added NickD I can run the snippet without errors now: thanks! One more nit: simplified-data is not used any longer, so you can get rid of one of the calls to simplify-org-data in org-tree-to-json.
Sep 26, 2022 at 12:59 comment added user31220 To add to my earlier comment, one can flatten the :parent references to an "id" by using org-export-get-reference. In other words, there is no need to strip :parent; it can be replaced with org ids. This way one get richer json data with :parent (but without the buffer positions). (The prefix org-export in org-export-get-reference is a hint that it is meant for use within an export context; IME, setting info to nil in org-export-* APIs usually "works")
Sep 26, 2022 at 12:35 comment added user31220 I have fixed the snippet now. Try again. If it works, says so. The snippet I have shared goes miles beyond the scope of the original question (obviously), and the snippet could be useful for people who want to work with js-data (as opposed to lisp data).
Sep 26, 2022 at 12:34 comment added user31220 Thanks. I was trying to use -tree-map or -tree-map-nodes and found it unsatisfactory. That is where the back history of -transform . -transform synonymous with simplify-org-data. The data (or the parse tree) gets simplified in two senses (a) The buffer positions of parsing tokens are stripped; the properties that are null are stripped (b) The :parent property is removed. (With the :parent property lurking around, the lisp structure will be cyclic, and you will run in to issues with json-encode. Try again. I will be happy to correct any further problems.
Sep 26, 2022 at 12:28 history edited user31220 CC BY-SA 4.0
added 31 characters in body
Sep 26, 2022 at 11:58 comment added NickD The first tree should be in-data in org-tree-to-json. The second tree should be simplified-data - maybe? Where does -transform come from? I guessed from dash.el but it doesn't seem to be defined there, at least in the version I have.
Sep 26, 2022 at 6:45 history edited user31220 CC BY-SA 4.0
added 72 characters in body
Sep 26, 2022 at 6:27 history answered user31220 CC BY-SA 4.0