Skip to content

Instantly share code, notes, and snippets.

@donlindsay
Created January 26, 2015 02:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donlindsay/829d5ffb059aca232261 to your computer and use it in GitHub Desktop.
Save donlindsay/829d5ffb059aca232261 to your computer and use it in GitHub Desktop.
org-as-json-to-file
(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)))))
@donlindsay
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment