Hi, this might be some stupid questions, but I can’t find the answers:

If I load the json module (\usemodule[json]) in TeX, I can use
utilities.json.field("name", "fieldname") in Lua.

– Is there a way to access the root object?
– Where is "field" implemented?
– How should I load/enable that module in Lua code (CLD)?


Reason: My JSON input has a recursive "sections" structure, like

{
        "title": "Chapter",
        "intro": "Some text",
        "sections": [
                {
                        "title": "Section 1",
                        "intro": "some text",
                        "sections": [
                                …
                        ]
                },
                { "title": "Section 2", … }
        ]
}

It was easy to write a Lua function that handles the sections recursively (\startsectionlevel is my friend), but I don’t understand how to start with the chapter. There are some more fields that are the same on all levels, I don’t want to repeat the code.

Hraban

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

Reply via email to