I would like to generate LaTeX template based on JSON Input. It is possible to take JSON as input in LaTeX3 and create LaTeX template? I had the solutions are found in LuaLaTeX.

Ways to parse JSON in LaTeX?

How do achieve this in LaTeX3? My JSON Input is below:

    "LaTeXPage": {
        "obj": "LaTeXPage",
        "pro": {
            "paperWidth": {
                "property": "paperWidth",
                "value": "129",
                "units": "mm",
                "remarks": null
            "paperHeight": {
                "property": "paperHeight",
                "value": "198",
                "units": "mm",
            "topMargin": {
                "property": "topMargin",
                "value": "3",
                "units": "mm",

Expected LaTeX Package output:


Especially i would like to use expl3 LaTeX Package. Or anyother solutions also welcome!!!

  • Why don't you use LuaLaTeX and a real JSON parser library?
    – TeXnician
    Apr 18 '20 at 22:01
  • @TeXnician: I have knowledge in LaTeX only and i'm new in LuaLaTeX. So i would like to do in LaTeX. Any solution greatly appreciate.
    – Balaji
    Apr 19 '20 at 3:32
  • @TeXnician: I had tried many ways and not found the solution. Could you please provide LuaLaTeX solution?
    – Balaji
    Apr 23 '20 at 16:58

I have found the solution.

\usepackage{luatextra} % luacode
\usepackage{environ}  % LaTeX Stylefile Writing in NewEnvironment

% load json file
function read(File)
    local handler = io.open(File, "rb")
    local content = handler:read("*all")
    return content

JSON = (loadfile "JSON.lua")()
tab = JSON:decode(read("sample.json"))




Pagewidth values is ::  {\JSONpagewidth}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.