Am 08.10.25 um 11:39 schrieb Hans Hagen via ntg-context:
On 10/8/2025 10:25 AM, Henning Hraban Ramm wrote:
Am 08.10.25 um 10:00 schrieb mf:
you don't need the \usemodule any more.

local object = utilities.json.load("myfile.json")

and you get your json as a lua table.

Thank you!
I need to run it on a server with TeXlive 2023, and there the module is still needed. But it works, and the code is much simpler than before.

Here is your monthly undocumented feature:

Thank you! Sorry, I overlooked your answer.

\usemodule[json]

\starttext

\startluacode
     local t = {
         a = {
             b = {
                 c = "here",
             }
         },
         b = "there",
         d = { 1, 2, 3, 4 },
     }

     utilities.tablestore.load("crap",t)

     io.savedata("oeps.json",utilities.json.tojson(t))
\stopluacode

\tablefield {crap}{a.b.c}
\tablefield {crap}{b}
\tablelength{crap}{d}

\loadtable[whatever][oeps.json]

\tablefield {whatever}{a.b.c}
\tablefield {whatever}{b}
\tablelength{whatever}{d}

\stoptext

I could probably extend this a bit (and then optimize it performance wise) but I have zero application for it; typical stuff that evolves in a project.

At the moment, I only need to read in the structure and handle it in Lua (CLD), no need for extensions.
But I’ll happily document this.

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