This response has to be read in conjuction with https://emacs.stackexchange.com/a/73824/31220
- Copy the below snippet to
todo.json
- Put your cursor on
#+begin_src emacs-lisp ...
and do C-c C-c
.
- Ensure that the resulting
json
src_block
reflect the state of the checklist
** TODO Organize party [2/4]
:PROPERTIES:
:ID: checklist
:END:
- [-] call people [1/3]
- [ ] Peter
- [X] Sarah
- [ ] Sam
- [X] order food
- [ ] think about what music to play
- [X] talk to the neighbors
#+name: checklist-json
#+begin_src emacs-lisp :result value verbatim :wrap src json
(org-tree-to-json (org-element-map (org-element-parse-buffer) 'headline
(lambda (headline)
(when (string= (org-element-property :ID
headline)
"checklist")
headline))
nil
t))
#+end_src
#+RESULTS: checklist-json
#+begin_src json
[
"org-data",
null,
[
"headline",
{
"raw-value": "Organize party [2/4]",
"level": 1,
"todo-keyword": "TODO",
"todo-type": "todo",
"title": [
"Organize party ",
[
"statistics-cookie",
{
"value": "[2/4]"
}
]
]
},
[
"section",
null,
[
"plain-list",
{
"type": "unordered"
},
[
"item",
{
"bullet": "- ",
"checkbox": "trans"
},
[
"paragraph",
null,
"call people ",
[
"statistics-cookie",
{
"value": "[1/3]"
}
],
"\n"
],
[
"plain-list",
{
"type": "unordered"
},
[
"item",
{
"bullet": "- ",
"checkbox": "off"
},
[
"paragraph",
null,
"Peter\n"
]
],
[
"item",
{
"bullet": "- ",
"checkbox": "on"
},
[
"paragraph",
null,
"Sarah\n"
]
],
[
"item",
{
"bullet": "- ",
"checkbox": "off"
},
[
"paragraph",
null,
"Sam\n"
]
]
]
],
[
"item",
{
"bullet": "- ",
"checkbox": "on"
},
[
"paragraph",
null,
"order food\n"
]
],
[
"item",
{
"bullet": "- ",
"checkbox": "off"
},
[
"paragraph",
null,
"think about what music to play\n"
]
],
[
"item",
{
"bullet": "- ",
"checkbox": "on"
},
[
"paragraph",
null,
"talk to the neighbors\n"
]
]
]
]
]
]
#+end_src
#+RESULTS:
#+begin_src json
[
"org-data",
null,
[
"headline",
{
"raw-value": "Organize party [2/4]",
"level": 1,
"todo-keyword": "TODO",
"todo-type": "todo",
"title": [
"Organize party ",
[
"statistics-cookie",
{
"value": "[2/4]"
}
]
]
},
[
"section",
null,
[
"plain-list",
{
"type": "unordered"
},
[
"item",
{
"bullet": "- ",
"checkbox": "trans"
},
[
"paragraph",
null,
"call people ",
[
"statistics-cookie",
{
"value": "[1/3]"
}
],
"\n"
],
[
"plain-list",
{
"type": "unordered"
},
[
"item",
{
"bullet": "- ",
"checkbox": "off"
},
[
"paragraph",
null,
"Peter\n"
]
],
[
"item",
{
"bullet": "- ",
"checkbox": "on"
},
[
"paragraph",
null,
"Sarah\n"
]
],
[
"item",
{
"bullet": "- ",
"checkbox": "off"
},
[
"paragraph",
null,
"Sam\n"
]
]
]
],
[
"item",
{
"bullet": "- ",
"checkbox": "on"
},
[
"paragraph",
null,
"order food\n"
]
],
[
"item",
{
"bullet": "- ",
"checkbox": "off"
},
[
"paragraph",
null,
"think about what music to play\n"
]
],
[
"item",
{
"bullet": "- ",
"checkbox": "on"
},
[
"paragraph",
null,
"talk to the neighbors\n"
]
]
]
]
]
]
#+end_src
json_print
is not known to my emacs (there is ajson-pretty-print
fromjson.el
but nojson_print
) and the rest is eitherr pseudocode or a syntax error. Why don't you describe what output you expect and leave it at that? Also specify where the output is to go: in the Org mode buffer, some other buffer, to a file? While you are at it, you should also fix the Org mode file to make it legal, Are you expecting the source block to be in the same file always, or are you interested in a more general function? If the latter, how is the input list specified?json
code; how does it look like; do they look likeimport module
etc) Think about it. The example I have added show that the org mode checklist are pretty compex (that is, they could be nested), so your assumption that it is a simple checklist is a bit of an approximation. You need to think more about how the output looks like. My guess is you don't needjson
; are you importing in tohaskell
orjs
orpython
.