This should work in a recent Emacs.

    (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)))))

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D

Reply via email to