This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'json) | |
(defun org-as-json-to-file (&optional path) | |
"Export the current Org-mode buffer as JSON to the supplied PATH." | |
(interactive "Fwrite to file: ") | |
(let ((tree (org-element-parse-buffer))) | |
(org-element-map tree | |
(append org-element-all-objects org-element-all-elements) | |
(lambda (el) (org-element-put-property el :parent nil))) | |
(with-temp-file path | |
(insert (json-encode tree))))) |