Debian Codegraph @

texmf-dist/doc/latex/jsonparse/jsonparse-doc.tex

raw
1 % File: jsonparse-doc.tex
2 % Copyright 2024-2026 Jasper Habicht (mail(at)jasperhabicht.de).
3 %
4 % This work may be distributed and/or modified under the
5 % conditions of the LaTeX Project Public License version 1.3c,
6 % available at http://www.latex-project.org/lppl/.
7 %
8 % This file is part of the `jsonparse' package (The Work in LPPL)
9 % and all files in that bundle must be distributed together.
10 %
11 % This work has the LPPL maintenance status `maintained'.
12 %
13 \documentclass[a4paper]{article}
14 \def\jsonparsefileversion{1.7.2}
15 \def\jsonparsefiledate{15 April 2026}
16
17 \usepackage[T1]{fontenc}
18 \usepackage{Alegreya}
19 \usepackage{AlegreyaSans}
20 \usepackage{FiraMono}
21
22 \usepackage{geometry, longtable, booktabs, siunitx, tcolorbox, hyperref}
23 \geometry{margin=25mm, left=45mm}
24 \urlstyle{same}
25
26 \usepackage{pgfplots}
27 \pgfplotsset{compat=1.18}
28
29 \usepackage{fancyhdr}
30 \pagestyle{fancy}
31 \fancyhf{}
32 \renewcommand{\headrulewidth}{0pt}
33 \fancyfoot[R]{\thepage}
34
35 \ExplSyntaxOn
36 \NewDocumentCommand{\fnstars}{m}{
37 \int_step_inline:nn { \value{#1} } { * }
38 }
39 \ExplSyntaxOff
40
41 \linespread{1.1}\selectfont
42 \addtolength{\skip\footins}{1em plus 5pt}
43 \makeatletter
44 \renewcommand*{\thefootnote}{\fnstars{footnote}}
45 \renewcommand{\@makefnmark}{\normalfont\@thefnmark}
46 \renewcommand{\@makefntext}[1]{%
47 \noindent\hbox to 1em{\normalfont\@thefnmark\hss}~#1%
48 }
49 \makeatother
50
51 \tcbuselibrary{skins,listings}
52 \lstdefinestyle{jsonparsedocmacro}{
53 basicstyle=\small\ttfamily,
54 literate=*{<}{{{\color{black!50}\guilsinglleft}}}1
55 {>}{{{\color{black!50}\guilsinglright}}}1,
56 keywords={},
57 moredelim=[is][\bfseries]{|}{|},
58 moredelim=[is][\bfseries\itshape]{?}{?},
59 moredelim=[is][\color{black!50}]{!}{!},
60 }
61 \lstdefinestyle{jsonparsedoccodeexample}{
62 basicstyle=\small\ttfamily,
63 keywords={},
64 }
65
66 \hypersetup{colorlinks}
67
68 \ExplSyntaxOn
69 \int_new:N \l_jsonparse_doc_change_int
70 \NewDocumentCommand{\changes}{ m m m }{
71 \int_incr:N \l_jsonparse_doc_change_int
72 \prop_new:c { l_jsonparse_doc_change_
73 \int_to_roman:n { \l_jsonparse_doc_change_int } _prop }
74 \prop_put:cnn { l_jsonparse_doc_change_
75 \int_to_roman:n { \l_jsonparse_doc_change_int } _prop } { version } {#1}
76 \prop_put:cnn { l_jsonparse_doc_change_
77 \int_to_roman:n { \l_jsonparse_doc_change_int } _prop } { date } {#2}
78 \prop_put:cnn { l_jsonparse_doc_change_
79 \int_to_roman:n { \l_jsonparse_doc_change_int } _prop } { changes } {#3}
80 }
81 \NewDocumentCommand{\printchanges}{ }{
82 \section{Changes}
83 \begin{description}
84 \setlength\itemsep{0pt}
85 \int_step_inline:nn { \l_jsonparse_doc_change_int } {
86 \item[
87 \prop_item:cn { l_jsonparse_doc_change_
88 \int_to_roman:n { ##1 } _prop } { version } ~
89 \normalfont{ (
90 \prop_item:cn { l_jsonparse_doc_change_
91 \int_to_roman:n { ##1 } _prop } { date }
92 ) }
93 ]
94 \prop_item:cn { l_jsonparse_doc_change_
95 \int_to_roman:n { ##1 } _prop } { changes }
96 }
97 \end{description}
98 }
99
100 \tl_new:N \l_jsonparse_doc_doctitle_tl
101 \NewExpandableDocumentCommand{\makedoctitle}{ o m o m m o m }{
102 \hypersetup{
103 pdfauthor={#5},
104 pdftitle={\IfValueTF{#1}{#1}{#2}},
105 pdfsubject={\IfValueTF{#3}{#3}{#4}}
106 }
107 \tl_set:Nn \l_jsonparse_doc_doctitle_tl {
108 \group_begin:
109 \tcbset{
110 title ~ style ~ hook/.style={
111 boxrule=2pt,
112 fontupper=\huge\ttfamily
113 }
114 }
115 \setlength{\parindent}{0pt}\sffamily
116 \Huge{\bfseries #2}\par\bigskip
117 \Large #4\par\bigskip
118 \large #5
119 \IfValueT{#6}{
120 \,\footnote{#6}\par\bigskip
121 }
122 #7\par\bigskip
123 \rule{\textwidth}{.08em}
124 \group_end:
125 }
126 }
127
128 \NewExpandableDocumentCommand{\printdoctitle}{ }{
129 \tl_use:N \l_jsonparse_doc_doctitle_tl
130 }
131 \ExplSyntaxOff
132
133 \NewDocumentCommand{\expandablestarcode}{ O{0,0} }{
134 \fill[black!50, shift={([xshift={-10pt}, yshift={-10pt-0.5em}]#1)}]
135 (90:3.75pt)
136 \foreach \i in {1,...,4} {
137 -- ({90+360/5*\i*2}:3.75pt)
138 } -- cycle;
139 }
140
141 \NewDocumentCommand{\expandablestar}{}{
142 \tikz{\expandablestarcode}
143 }
144
145 \NewDocumentCommand{\warning}{}{%
146 \begin{tikzpicture}[overlay, baseline={(w.base)}]
147 \node[circle, fill, black!25!red!10, text=black!25!red, outer sep=0pt]
148 (w) at (-3em,0pt) {\bfseries !};
149 \fill[black!25!red!10]
150 (w.east) |- (w.south) -- cycle;
151 \end{tikzpicture}%
152 }
153
154 \tcbset{
155 size=small,
156 arc=2.5pt,
157 outer arc=2.5pt,
158 colframe=black!10,
159 colback=black!10,
160 title style hook/.style={},
161 }
162
163 \NewTCBListing{macrodef}{ s o }{
164 listing only,
165 listing style={jsonparsedocmacro},
166 grow to left by=2cm,
167 boxrule=0pt,
168 after={\par\smallskip\noindent},
169 enhanced,
170 IfValueT={#2}{
171 hypertarget=#2
172 },
173 IfBooleanT={#1}{
174 overlay={
175 \expandablestarcode[frame.north east]
176 }
177 }
178 }
179
180 \NewTCBListing{codeexample}{ }{
181 listing only,
182 listing style={jsonparsedoccodeexample},
183 after={\par\smallskip\noindent}
184 }
185
186 \NewTCBListing{codeexamplecolumns}{ }{
187 text side listing,
188 lefthand width=4.5cm,
189 listing style={jsonparsedoccodeexample},
190 after={\par\smallskip\noindent}
191 }
192
193 \NewTCBListing{macrodeprecated}{ s }{
194 listing only,
195 listing style={jsonparsedocmacro},
196 boxrule=0pt,
197 width={0.5\linewidth-2.5pt},
198 box align=top,
199 after=\hfill,
200 colframe=black!25!red!10,
201 colback=black!25!red!10,
202 enhanced,
203 IfBooleanT={#1}{
204 overlay={
205 \fill[black!25!red!10]
206 ([yshift={5pt-1.5em}]frame.north east)
207 -- ++(5pt,-5pt) -- ++(-5pt,-5pt)
208 -- cycle;
209 }
210 }
211 }
212
213 \NewTCBListing{macroreplacement}{ }{
214 listing only,
215 listing style={jsonparsedocmacro},
216 boxrule=0pt,
217 width={0.5\linewidth-2.5pt},
218 box align=top,
219 before={},
220 colframe=black!25!green!10,
221 colback=black!25!green!10
222 }
223
224 \NewTotalTCBox{\macro}{ O{} v }{
225 verbatim,
226 size=tight,
227 arc=1pt,
228 outer arc=1pt,
229 top=0.5pt,
230 bottom=0.5pt,
231 left=2pt,
232 right=2pt,
233 boxrule=0pt,
234 colframe=black!10,
235 colback=black!10,
236 fontupper=\small\ttfamily,
237 #1
238 }{\vphantom{/g}\lstinline^#2^}
239
240 \NewTotalTCBox{\titlemacro}{ s O{} m }{
241 verbatim,
242 size=tight,
243 arc=1pt,
244 outer arc=1pt,
245 top=0.5pt,
246 bottom=0.5pt,
247 left=2pt,
248 right=2pt,
249 boxrule=0pt,
250 colframe=black!10,
251 colback=black!10,
252 fontupper=\small\ttfamily,
253 title style hook,
254 #2
255 }{\vphantom{/g}\IfBooleanT{#1}{\textbackslash}#3}
256
257 \usepackage{jsonparse}
258
259 \makedoctitle
260 [The jsonparse package]
261 {The \titlemacro{jsonparse} package}
262 {A handy way to parse, store and access JSON data from files or strings in LaTeX documents}
263 {Jasper Habicht}[E-mail: \href{mailto:[email protected]}{[email protected]}. I am grateful to Joseph Wright, Jonathan P. Spratte and David Carlisle who helped me navigating the peculiarities of TeX and optimizing the code. Jason, the JSON parsing horse: \textcopyright{} 2024--2026 Hannah Klöber.]
264 {Version \jsonparsefileversion, released on \jsonparsefiledate}
265
266 %\changes{v0.3.0}{2024/04/08}{First public beta release.}
267 \changes{v0.5.0}{2024/04/09}{Changed from string token variables to token lists to support Unicode.}
268 %\changes{v0.5.5}{2024/04/09}{Bug fixes, introduction and enhancement of user functions.}
269 \changes{v0.5.6}{2024/04/11}{Bug fixes, escaping of special chars added.}
270 \changes{v0.5.7}{2024/04/14}{Bug fixes, key-value option setting added.}
271 %\changes{v0.6.0}{2024/04/15}{Bug fixes, renaming of several commands.}
272 \changes{v0.7.0}{2024/04/18}{Renaming and rearranging of keys, escaping of special JSON escape sequences added.}
273 \changes{v0.7.1}{2024/04/20}{Access to top-level keys of object added.}
274 \changes{v0.8.0}{2024/04/24}{Internal rewrite, escaping procedures changed.}
275 \changes{v0.8.2}{2024/04/26}{Bug fixes, externalizing parsed data.}
276 \changes{v0.8.3}{2024/04/28}{Escaping of characters with special meaning in TeX.}
277 %\changes{v0.8.5}{2024/05/05}{Enhanced key management.}
278 %\changes{v0.8.6}{2024/05/09}{Bug fix in nesting function.}
279 %\changes{v0.8.7}{2024/08/08}{Corrections in documentation, error messages.}
280 \changes{v0.9.0}{2024/08/27}{Adaption to updated verbatim tokenization.}
281 \changes{v0.9.1}{2024/09/21}{Added functions to test for valid JSON numbers.}
282 \changes{v0.9.3}{2024/10/24}{Fixed a bug that prevented tabs in source from being parsed properly.}
283 %\changes{v0.9.5}{2024/10/27}{Streamlining of code, clarification of explanations in documentation.}
284 \changes{v0.9.6}{2024/10/31}{Allowing for multiple return values when mapping over arrays.}
285 %\changes{v0.9.7}{2024/11/05}{Streamlining of code, ensuring backward compatibility.}
286 \changes{v0.9.8}{2024/11/19}{Bug fixes; adding possibility to store value in token list.}
287 %\changes{v0.9.10}{2024/12/10}{Enhanced backward compatibility; switching to linked property lists.}
288 %\changes{v0.9.11}{2025/01/15}{Bug fixes; adding additional command to loop through arrays.}
289 \changes{v0.9.12}{2025/01/17}{Bug fixes; adding commands to access items in arrays.}
290 %\changes{v1.0.0}{2025/01/20}{Streamlining of code, unification of command structure.}
291 \changes{v1.0.1}{2025/01/21}{Fixes in documentation. Added user command for filtering.}
292 \changes{v1.0.2}{2025/01/23}{Support for Unicode surrogate pairs.}
293 %\changes{v1.0.3}{2025/01/26}{Test for valid JSON numbers expandable.}
294 \changes{v1.1.0}{2025/01/30}{Unified names of user functions; renaming key for keywords.}
295 \changes{v1.1.1}{2025/02/03}{Added option to store result of mapped inline function.}
296 \changes{v1.1.2}{2025/02/08}{Added option to store result of array function.}
297 %\changes{v1.1.3}{2025/02/13}{Bug fixes.}
298 %\changes{v1.2.0}{2025/02/22}{Unified option to store result.}
299 \changes{v1.2.1}{2025/02/24}{Unified functions, added option to store result globally.}
300 %\changes{v1.2.2}{2025/02/25}{Fixes in documentation.}
301 \changes{v1.2.3}{2025/03/23}{Enabled nesting of mapped inline function.}
302 \changes{v1.3.0}{2025/03/25}{Enhancements in key setting mechanism.}
303 %\changes{v1.3.1}{2025/03/30}{Fixes in documentation. Bug fixes.}
304 %\changes{v1.3.2}{2025/04/07}{Bug fixes and code improvements.}
305 \changes{v1.4.0}{2025/04/10}{Enhancements in parsing speed.}
306 \changes{v1.5.0}{2025/04/20}{Enhancements in parsing speed. Bug fixes.}
307 %\changes{v1.5.1}{2025/05/05}{Bug fixes.}
308 %\changes{v1.5.2}{2025/05/06}{Bug fixes.}
309 \changes{v1.6.0}{2025/05/10}{Renaming of L3 functions. Bug fixes.}
310 %\changes{v1.6.1}{2025/06/03}{Bug fixes. FAQ in documentation.}
311 %\changes{v1.6.5}{2025/08/11}{Bug fixes.}
312 \changes{v1.6.6}{2025/08/27}{Various improvements. Added sockets for preparsing.}
313 %\changes{v1.6.7}{2025/10/07}{Enhanced backward compatibility.}
314 %\changes{v1.6.8}{2025/11/24}{Corrections and clarifications in documentation.}
315 \changes{v1.6.9}{2025/12/03}{Added option to locally assign plug to socket.}
316 %\changes{v1.6.10}{2025/12/10}{Added timestamp to externalized files.}
317 \changes{v1.6.11}{2026/01/18}{Added option to locally set zero-based indexing for mapping functions.}
318 %\changes{v1.6.12}{2026/01/20}{Fix in error handling.}
319 \changes{v1.7.0}{2026/01/22}{Improved expandability in mapping functions.}
320 %\changes{v1.7.1}{2026/01/28}{Minor improvement in array count function.}
321 %\changes{v1.7.2}{2026/04/15}{Corrections in documentation.}
322
323 \begin{document}
324 \vspace*{-1cm}
325 \noindent\hspace*{-3.5mm}\includegraphics[width=5cm]{jason/jason.pdf}
326
327 \printdoctitle
328
329 \bigskip
330
331 \section{Introduction}
332
333 Hello guys, I am Jason, the JSON parsing horse. JSON data is my favorite thing to parse! But I found that converting JSON to TeX can be a bit tricky. Therefore, I created this package which I am happy to introduce to you.\footnote{Credit for the idea of Jason, the JSON parsing horse, goes to Paulo Cereda and the circumstance of his presumably insufficiently illuminated workplace (or his late working hours).}
334
335 The \macro{jsonparse} package provides a handy way to read in JSON data from files or strings in LaTeX documents, parse the data and store it in a user-defined token variable. The package allows accessing the stored data via a JavaScript-flavored syntax.
336
337 The package is continuously being tested, but bugs cannot be ruled out. The author is grateful for reporting any bugs via GitHub at \url{https://github.com/jasperhabicht/jsonparse/issues}. A site for asking questions about the package and for suggestions for improvement is available at \url{https://github.com/jasperhabicht/jsonparse/discussions}.
338
339 \section{Frequently asked questions}
340
341 \subsection{Why does a comparison of two equal strings return false?}
342
343 Note that you probably need to use \macro{\JSONParseExpandableValue} if you want to compare a value from parsed JSON data with the contents of another token list. See the explanation \hyperlink{macro:expandablevalue}{below} for more details.
344
345 Also note that \macro{\JSONParseExpandableValue} returns a string with specific category codes, namely category code 12 (``other'') for all characters except spaces. Therefore, you need to test against another string. You can use \macro{\detokenize} for conversion. See section \ref{sec:general} for more information.
346
347 \subsection{Why does parsing take so long?}
348
349 Make sure that you use the most recent version of the package. Parsing speed is constantly being monitored and updates typically increase parsing speed.
350
351 If you don't need to access whole objects or arrays from the JSON data, you can set the key \macro{skip structures} which should increase parsing speed. See the explanation \hyperlink{key:skipstructures}{below} for more details.
352
353 If the JSON data contains a considerable amount of numbers, parsing speed can be increased slightly by setting \macro{validate numbers=false}. See the explanation \hyperlink{key:validatenumbers}{below} for more details.
354
355 If the JSON data does not change often, you can externalize the parsed result by setting the key \macro{externalize}. See section \ref{sec:externalizing} for more information.
356
357 \section{Loading the package}
358
359 To install the package, copy the package file \macro{jsonparse.sty} into the working directory or into the \macro{texmf} directory. After the package has been installed, the \macro{jsonparse} package is loaded by calling \macro{\usepackage{jsonparse}} in the preamble of the document.
360
361 The package can be used with PDFLaTeX, LuaLaTeX or XeLaTeX. It should also work with upTeX. The package does not load any dependencies, but it needs a LaTeX kernel of 1 June 2022 or newer. It is recommended to use the package with an up-to-date TeX distribution.
362
363 \begin{macrodef}
364 |debug|
365 \end{macrodef}
366 The package can be loaded with the option \macro{debug}. It will then output to the log file every instance of a string, a boolean (true or false) value, a null value, a number as well as the start and end of every object and the start and end of every array that is found while parsing the JSON string or JSON file. It will also show the relevant keys associated to the values. If the key \macro{skip structures} is not set (or not set to \macro{true}), objects and arrays will be shown as values to the respective keys, including the pseudo key \macro{.} (or the string defined using the key \macro{separator/child}) that represents the complete JSON string.
367
368 Let us assume that the following JSON data is parsed:
369
370 \begin{codeexample}
371 {
372 "string" : "a" ,
373 "boolean true" : true ,
374 "boolean false" : false ,
375 "null" : null ,
376 "number" : -1.1e-1 ,
377 "array" : [ "a" , "b" , "c" ]
378 }
379 \end{codeexample}
380
381 This will then result in the following output to the log:
382
383 \begin{codeexample}
384 Parsing JSON ...
385 (obj begin)
386 (key) string:
387 (str) a
388 (key) boolean true:
389 (tru) true
390 (key) boolean false:
391 (fal) false
392 (key) null:
393 (nul) null
394 (key) number:
395 (num) -1.1e-1
396 (arr begin)
397 (key) array[0]:
398 (str) a
399 (key) array[1]:
400 (str) b
401 (key) array[2]:
402 (str) c
403 (key) array:
404 (arr) [ "a" , "b" , "c" ]
405 (arr end)
406 (key) .:
407 (obj) { "string" : "a" , "boolean true" : true , "boolean false" :
408 false , "null" : null , "number" : -1.1e-1 , "array" : [ "a" ,
409 "b" , "c" ] }
410 (obj end)
411 JSON parsing done.
412 \end{codeexample}
413
414 The \macro{debug} key can be set either as package option or using \macro{\JSONParseSet}. It can also be set locally as option to the commands \macro{\JSONParse} and \macro{\JSONParseFromFile}.
415
416 \section{General remarks of the parsing procedure}\label{sec:general}
417
418 In general, the package will read and store the JSON source and data as string, which means that all characters have category code 12 (``other''), except for spaces and (horizontal) tabs which have category code 10 (``space''). The \macro{\endlinechar} value is set to $-$1 which means that linefeeds and carriage returns are ignored by TeX. These settings are in line with the JSON specification of handling whitespace. Furthermore, if PDFLaTeX is used, the upper-half of the 8-bit range is set to ``active''. Additionally, JSON defines a small set of escape sequences and in order to be able to process these, the category code of the backslash is set to 0 (``escape'').
419
420 During parsing, the package identifies JSON objects, arrays, strings, numbers, boolean values and null values from the JSON data. It stores all these values together with the relevant keys in a property list. Once the parsing process is done, every value can be retrieved from the property list by calling the relevant key. The package ignores whitespace in the JSON data. In general, the package accepts any valid JSON data. If a key is defined multiple times, the latter definition will silently overwrite the former.
421
422 \section{Escaping and special treatment of the input}\label{sec:escaping}
423
424 JSON strings cannot contain the two characters \macro{"} and \macro{\}. These two characters need to be escaped with a preceding backslash (\macro{\}). This package therefore (re)defines locally the TeX control symbols \macro{\"}, \macro{\/}, \macro{\\}, \macro{\b}, \macro{\f}, \macro{\n}, \macro{\r}, \macro{\t} and \macro{\u}. These control symbols are prevented from expanding during parsing. For example, \macro{\"} is defined as \macro{\exp_not:N \"} and only expanded to \macro{"} when typeset, which ensures that strings are parsed properly.
425
426 Similarly, the control symbol \macro{\/} expands eventually to \macro{/} and \macro{\\} to \macro{\c_backslash_str} (i.\,e.\ a backslash with category code 12).
427
428 The escape sequence \macro{\u} followed by a hex value consisting of four digits eventually expands to \macro{\codepoint_generate:nn} that creates the character represented by the relevant four hex digits with category code 12 (``other''). If two escape sequences \macro{\u} with four hex digits each follow each other and together represent a Unicode surrogate pair, this surrogate pair is converted into the relevant Unicode codepoint.
429
430 The JSON escape sequences \macro{\b}, \macro{\f}, \macro{\n}, \macro{\r} and \macro{\t} eventually expand to token variables of which the contents can be set using the relevant \macro{replace} key. See more on setting options below in section \ref{sec:options}.
431
432 It is possible to insert TeX macros to the JSON source that will eventually be expanded just before typesetting. Backslashes of TeX macros need to be escaped by another backslash. The TeX macros \macro{\"} and \macro{\\} must be escaped again in the JSON source so that they become \macro{\\\"} and \macro{\\\\} respectively.
433
434 \begin{macrodef}
435 |\$|{<token variable name>}{<key>}
436 \end{macrodef}
437 Using the control sequence \macro{\$}, it is possible to nest JSON strings into each other. Used inside the \macro{\JSONParse} command, the control sequence takes two arguments delimited by curly braces. The first argument represents the name of the token variable that holds the parsed JSON data where the inserted JSON string should be taken from. The second argument sets the key that should be selected. The following example shows a simple use case:
438
439 \begin{codeexamplecolumns}
440 \JSONParse{\myJSONdataA}{
441 { "a" : { "b" : "c" } }
442 }
443
444 \JSONParse{\myJSONdataB}{
445 { "d" : \${myJSONdataA}{a} }
446 }
447
448 \JSONParseValue{\myJSONdataB}{d.b}
449 \end{codeexamplecolumns}
450
451 \warning Note that the control sequence \macro{\$} is replaced by the value exactly. Therefore, if the value happens to be a string, the control sequence \macro{\$} should be placed between quotation marks (\macro{"}) in order for the resulting string to be valid JSON. The control sequence \macro{\$} is only available inside the \macro{\JSONParse} command, but not inside the \macro{\JSONParseFromFile} command.
452
453 \begin{macrodef}
454 |escape|={all}
455 |escape|={none}
456 |escape|={number sign}
457 |escape|={dollar sign}
458 |escape|={percent sign}
459 |escape|={ampersand}
460 |escape|={circumflex accent}
461 |escape|={low line}
462 |escape|={tilde}
463 \end{macrodef}
464 The key \macro{escape} can be used to convert characters that don't require escaping in JSON but in TeX into the relevant TeX escape sequences. Apart from the backslash and curly braces that need to be escaped anyways, these are the number sign, the dollar sign, the percent sign, the ampersand, the circumflex accent, the low line and the tilde. The characters can be selected individually or separated by a comma (for example \macro{escape={dollar sign, circumflex accent, low line}}). With \macro{escape={all}}, all escaping sequences are selected, with \macro{escape={none}}, none is selected.
465
466 The naming of the relevant characters follows their Unicode names. However, \macro{hash} exists as alias for \macro{number sign}, \macro{dollar} as alias for \macro{dollar sign}, \macro{percent} for \macro{percent sign}, \macro{circumflex} for \macro{circumflex accent} and \macro{underscore} for \macro{low line}.
467
468 This key can be set using \macro{\JSONParseSet}. It can also be set locally as option to the commands \macro{\JSONParseValue}, \macro{\JSONParseArrayUse} and \macro{\JSONParseArrayMapFunction}.
469
470 \begin{macrodef}
471 |rescan|
472 |rescan|={<boolean>}
473 \end{macrodef}
474 The key \macro{rescan} can be used to activate and deactivate rescanning of the output. This key is active per default. Rescanning converts all tokens to their default category codes and TeX control sequences are expanded before typesetting. Further, during the rescanning process, JSON escape sequences are replaced and characters that don't require escaping in JSON but in TeX are replaced by the relevant TeX escape sequences.
475
476 This key can be set using \macro{\JSONParseSet}. It can also be set locally as option to the commands \macro{\JSONParseValue}, \macro{\JSONParseArrayUse} and \macro{\JSONParseArrayMapFunction}.
477
478 \section{Main user commands}
479
480 The first part of this section describes the basic commands for parsing JSON data and retrieving values from parsed JSON data. The second part of this section describes the various commands for handling arrays provided by this package. Commands marked with a star (\expandablestar) are fully expandable.
481
482 \subsection{Basic parsing commands}
483
484 \begin{macrodef}
485 |\JSONParse|[<options>]{<token variable>}{<JSON string>}
486 \end{macrodef}
487 The command \macro{\JSONParse} is used to parse a JSON string and globally store the parsed result in a token variable (a property list). The first mandatory argument takes the name of the token variable that is created by the command. The second mandatory argument takes the JSON string to be parsed.
488
489 For example, using \macro{\JSONParse{\myJSONdata}{ { "key" : "value" } }}, the relevant JSON string will be parsed and the result stored in the token variable \macro{\myJSONdata} as property list. In this case, the property list only consists of two entries of which one has the key \macro{key} and the value \macro{value} and the other represents the whole object. Once the JSON string has been parsed, the command \macro{\JSONParseValue{\myJSONdata}{key}}, for example, can be used to extract the relevant value from this property list (see the description below).
490
491 The optional argument of the command \macro{\JSONParse} can be used to pass options to the command that are then applied locally.
492
493 \warning The command \macro{\JSONParse} takes the JSON string as verbatim argument which means that the command can't be used inside a macro argument. One consequence of this for example is that when using the \macro{beamer} document class, the command \macro{\JSONParse} can only be used inside the \macro{frame} environment if the \macro{fragile} option is set.
494
495 \begin{macrodef}
496 |\JSONParseFromFile|[<options>]{<token variable>}{<JSON file>}
497 \end{macrodef}
498 The command \macro{\JSONParseFromFile} is used to parse a JSON file and store the parsed result in a token variable (a property list). It works the same way as \macro{\JSONParse}, but instead of a JSON string, it takes as third argument the path to the JSON file relative to the working directory.
499
500 \begin{macrodef}
501 |\JSONParseValue|[<options>]{<token variable>}{<key>}
502 \end{macrodef}
503 The command \macro{\JSONParseValue} is used to select values from the token variable (property list) that has been created using the commands \macro{\JSONParse} or \macro{\JSONParseFromFile}. The first mandatory argument takes the token variable that holds the parsed JSON data. The second mandatory argument takes the key to select the relevant entry from the parsed JSON data using JavaScript syntax.
504
505 If the JSON string \macro{{ "key" : "value" }} is parsed into the token variable \macro{\myJSONdata}, using \macro{\JSONParseValue{\myJSONdata}{key}} would extract the value associated with the key \macro{key}, which in this case is \macro{value}, and typeset it to the document.
506
507 Nested objects and arrays are assigned keys that adhere to JavaScript syntax. For example, if the JSON string \macro{{ "outer_key" : { "inner_key" : "value" } }} is parsed into the token variable \macro{\myJSONdata}, to select the value associated with the key \macro{inner_key}, the command \macro{\JSONParseValue{\myJSONdata}{outer_key.inner_key}} can be used. To give an example for an array, the command \macro{\JSONParseValue{\myJSONdata}{key[0]}} selects the first value of the array associated with the key \macro{key} in the JSON string \macro{{ "key" : [ "one" , "two" ] }}.
508
509 The optional argument can be used to pass options such as \macro{escape} or \macro{rescan} to the command that are then applied locally. When the option \macro{rescan} is used, the token list is rescanned before it is typeset (which means that all category codes that may have been changed before are set to the default values). This is the default behavior. If rescanning is not desired, pass the option \macro{rescan=false} to the command.
510
511 When a key is associated with an object or array (and the key \macro{skip structures} is not set), the whole object or array is output as JSON string. Additionally, the special key \macro{.} (or the string defined using the key \macro{separator/child}) returns the whole JSON object (or the whole JSON array if the JSON data only consists of one array) as string where all characters (except for spaces and tabs) have category code 12 (``other'').
512
513 \warning The command \macro{\JSONParseValue} is not expandable and can therefore not be used as argument of certain other arguments where expansion is needed. In such cases, the expandable command \macro{\JSONParseExpandableValue} should be used.
514
515 \begin{macrodef}[key:storein]
516 |store in|={<token variable>}
517 \end{macrodef}
518 The command \macro{\JSONParseValue} accepts the key \macro{store in} that can be used to store the return value in another token variable. If the token variable given as option to the \macro{store in} key has not yet been defined, it will be created by this command.
519
520 Per default, the token list returned by this command is a string variable where all characters have category code 12 (``other''), except for spaces and (horizontal) tabs that have category code 10 (``space'').
521
522 The key \macro{store in} can be used together with the key \macro{rescan} to rescan the return value before storing it in the token variable. This means that the value stored in the token list will have the category codes TeX uses per default. Option settings such as the \macro{escape} option are taken into consideration during the rescan process.
523
524 This can, for example, be necessary when numbers stored in the JSON data in scientific format should be formatted using the \macro{siunitx} package. The rescan is needed here, because otherwise the character \macro{e} would have the wrong category code and would hence not be recognized by the formatting parser as exponent marker. Let us assume the key \macro{number} in some JSON source parsed into the token variable \macro{\myJSONnumber} represents the value \macro{-1.1e-1}, then the following could be used to format the output:
525
526 \JSONParse{\myJSONnumber}{ { "number" : -1.1e-1 } }
527 \begin{codeexamplecolumns}
528 \JSONParseValue
529 [rescan, store in=\mynumber]
530 {\myJSONnumber}{number}
531 \num{\mynumber}
532 \end{codeexamplecolumns}
533
534 The key \macro{store in} can also be set using \macro{\JSONParseSet}. Calling \macro{store in={}} will reset it to its default (empty) value.
535
536 \begin{macrodef}*[macro:expandablevalue]
537 |\JSONParseExpandableValue|{<token variable>}{<key>}
538 \end{macrodef}
539 Whole objects or arrays can be output as JSON string for further use in other macros using the expandable command \macro{\JSONParseExpandableValue}. The value that is returned by this command is typically a string variable where all characters have category code 12 (``other''), except for spaces and (horizontal) tabs that have category code 10 (``space''). This should be kept in mind if string comparisons should be made. A comparison against a token list with the default category codes used by TeX won't work, since letters will have category code 11 (``letter''), but it is possible to use \macro{\detokenize} to set the category codes of the token list in such a way that the comparison works.
540
541 For example, if the JSON string \macro{{ "key" : "value" }} has been parsed into the token variable \macro{\myJSONdata}, the command \macro{\JSONParseExpandableValue{\myJSONdata}{key}} will have the same meaning as \macro{\detokenize{value}} and expand to a token list with all characters having category code 12 (``other'').
542
543 \begin{macrodef}
544 |\JSONParseKeys|[<options>]{<token variable>}{<key>}
545 \end{macrodef}
546 The command \macro{\JSONParseKeys} is used to get all top-level keys of a JSON object as JSON array and return this array as string where all characters (except for spaces and tabs) have category code 12 (``other''). The first mandatory argument of the command takes the token variable that holds the parsed JSON data. The second mandatory argument takes the key to select the relevant entry from the parsed JSON data using JavaScript syntax.
547
548 The command \macro{\JSONParseKeys} accepts as option the key \macro{store in} to get all top-level keys of a JSON object as JSON array and parse this array into a token variable. Note that the return value is a property list in this case, not a string. The token variable to store the keys as array is created if it does not exist.
549
550 As an example, let us assume that the following JSON data structure is parsed into the token variable \macro{\myJSONdata}:
551
552 \begin{codeexample}
553 {
554 "array" : [
555 {
556 "key_a" : "one" ,
557 "key_b" : "two"
558 } ,
559 {
560 "key_a" : "three" ,
561 "key_b" : "four"
562 }
563 ]
564 }
565 \end{codeexample}
566 \JSONParse{\myJSONdata}{ { "array" : [ { "key_a" : "one" , "key_b" : "two" } , { "key_a" : "three" , "key_b" : "four" } ] } }
567
568 We can then generate an array consisting of all keys of the object that is the first item of the array using \macro{\JSONParseKeys{\myJSONdata}{array[0]}}. We can also generate an array consisting of all top-level keys of the parsed JSON data using \macro{\JSONParseKeys{\myJSONdata}{.}} where \macro{.} is the pseudo key representing the complete parsed JSON string. Note that in addition to the key of an array, keys for each item of this array will be added to the array of keys:
569
570 \begin{codeexamplecolumns}
571 \JSONParseKeys{\myJSONdata}{array[0]}
572
573 \JSONParseKeys{\myJSONdata}{.}
574 \end{codeexamplecolumns}
575
576 If we store such an array of keys in the token variable \macro{\myJSONkeys}, we can for example access the first item of this array of keys using \macro{\JSONParseValue{\myJSONkeys}{[0]}}:
577
578 \begin{codeexamplecolumns}
579 \JSONParseKeys[store in=\myJSONkeys]
580 {\myJSONdata}{.}
581 \JSONParseValue{\myJSONkeys}{[0]}
582 \end{codeexamplecolumns}
583
584 Note that the underscores in the names of the keys can be printed without changing to math mode in the above example because they are stored as strings where all characters (except for spaces and tabs) have category code 12 (``other'').
585
586 \begin{macrodef}
587 |\JSONParseFilter|{<token variable>}{<token variable>}{<key>}
588 \end{macrodef}
589 The command \macro{\JSONParseFilter} is used to select a part (such as an object or an array) of a JSON object or JSON array and parse this into a token variable (a property list). The first argument denotes the token variable where the value should be stored into. The second argument of the command takes the token variable that holds the parsed JSON data. The third argument takes the key to select the relevant entry from the parsed JSON data using JavaScript syntax.
590
591 \subsection{Commands for handling arrays}
592
593 The package offers a variety of commands that can be used to process JSON arrays. Three commands are provided to loop through arrays, \macro{\JSONParseArrayUse}, \macro{\JSONParseArrayMapFunction} and \macro{\JSONParseArrayMapInline} which offer different functionality for different use cases. All three commands are implemented in a unique way and it should not be expected that what works with one of these commands also works with another. The commands differ in various respects, for example:
594
595 \begin{itemize}
596 \item With \macro{\JSONParseArrayUse} and \macro{\JSONParseArrayMapInline}, it is possible to store the result in a token list for later use via the option key \macro{store in}, but such is not possible with \macro{\JSONParseArrayMapFunction}.
597 \item It is possible to store non-expandable commands (such as \macro{\emph} or \macro{\textbf}) in a token list using \macro{\JSONParseArrayUse}, but not using \macro{\JSONParseArrayMapInline}.
598 \end{itemize}
599
600 \begin{macrodef}
601 |\JSONParseArrayCount|[<options>]{<token variable>}{<key>}
602 \end{macrodef}
603 The command \macro{\JSONParseArrayCount} takes as first mandatory argument a token variable holding a parsed JSON string or JSON file and as second mandatory argument a key to select an array in the JSON data. It returns an integer representing the number of items contained in the selected array.
604
605 The command \macro{\JSONParseArrayCount} accepts the use of the key \macro{store in} to store the number of items contained in the selected array in a token variable.
606
607 \begin{macrodef}[macro:arrayuse]
608 |\JSONParseArrayUse|[<options>]{<token variable>}{<key>}[<subkey>]{<string>}
609 \end{macrodef}
610 The command \macro{\JSONParseArrayUse} is used to select all values from an array from a parsed JSON string or JSON file. The first mandatory argument takes the token variable that holds the parsed JSON data. The second mandatory argument takes the key to select the relevant entry from the parsed JSON data using JavaScript syntax. The second optional argument can be used to pass a subkey, i.\,e.\ a key that is used to select a value for every item. The last argument takes a string that is inserted between all values when they are typeset.
611
612 The first optional argument can be used to pass options to the command, such as \macro{escape} or \macro{rescan}, that are then applied locally.
613
614 Let us again assume the following JSON data structure being parsed into the token variable \macro{\myJSONdata}:
615
616 \begin{codeexample}
617 {
618 "array" : [
619 {
620 "key_a" : "one" ,
621 "key_b" : "two"
622 } ,
623 {
624 "key_a" : "three" ,
625 "key_b" : "four"
626 }
627 ]
628 }
629 \end{codeexample}
630
631 When using \macro{\JSONParseArrayUse{\myJSONdata}{array}[key_a]{, }}, `\JSONParseArrayUse{\myJSONdata}{array}[key_a]{, }' is then typeset to the document.
632
633 The command \macro{\JSONParseArrayUse} accepts as option set in the first optional argument the key \macro{store in} which takes a token variable into which the result of the command should be stored. Storing the result of the mapped inline function can be helpful if JSON data should be reformatted for use in another function.
634
635 \begin{codeexamplecolumns}
636 \JSONParseArrayUse[store in=\myJSONitems]
637 {\myJSONdata}{array}[key_a]{,}
638
639 \begin{tikzpicture}
640 \foreach \x [count=\i] in \myJSONitems {
641 \fill[blue] (\i,0) circle[radius=2pt]
642 node[above=5pt, black] {\x};
643 }
644 \end{tikzpicture}
645 \end{codeexamplecolumns}
646
647 The command \macro{\JSONParseArrayUse} also accepts as option set in the first optional argument the key \macro{zero-based} to set the initial value of the mapping counter to the intended value if the key \macro{zero-based} is not set globally.
648
649 \begin{macrodef}[macro:arraymapfunction]
650 |\JSONParseArrayMapFunction|[<options>]{<token variable>}{<key>}[<subkey>]
651 {<command>}
652 \end{macrodef}
653 The command \macro{\JSONParseArrayMapFunction} works in a similar way and takes the same first four arguments as the command \macro{\JSONParseArrayUse}. However, instead of a string that is added between the array items, it takes a command (a token list) as last argument. This command can be defined beforehand and will be called for every array item. Inside its definition, the commands \macro{\JSONParseArrayIndex}, \macro{\JSONParseArrayKey} and \macro{\JSONParseArrayValue} can be used which are updated for each item and output the index, the key and the value of the current item respectively. Note that these commands are defined globally to make accessing them as easy as possible.
654
655 For example, let us assume the same JSON data structure as defined above parsed into the token variable \macro{\myJSONdata}. Then, the following can be done:
656
657 \begin{codeexamplecolumns}
658 \newcommand{\myJSONitem}{
659 \item \emph{\JSONParseArrayValue}
660 }
661
662 \begin{itemize}
663 \JSONParseArrayMapFunction{\myJSONdata}
664 {array}[key_a]{\myJSONitem}
665 \end{itemize}
666 \end{codeexamplecolumns}
667
668 It is possible to make use of multiple subkeys by passing them as a comma separated list as fourth argument to the command. Inside the command that is called for every array item, the different keys and values can be accessed via commands numbered with uppercase Roman numerals such as \macro{\JSONParseArrayKeyI}, \macro{\JSONParseArrayKeyII}, \macro{\JSONParseArrayKeyIII} etc.\ and \macro{\JSONParseArrayValueI}, \macro{\JSONParseArrayValueII}, \macro{\JSONParseArrayValueIII} etc.
669
670 We can extend the above example in the following way:
671
672 \begin{codeexamplecolumns}
673 \newcommand{\myJSONitem}{
674 \item \emph{\JSONParseArrayValueI :}
675 \JSONParseArrayValueII
676 }
677
678 \begin{itemize}
679 \JSONParseArrayMapFunction{\myJSONdata}
680 {array}[key_a,key_b]{\myJSONitem}
681 \end{itemize}
682 \end{codeexamplecolumns}
683
684 \begin{macrodef}
685 |code before|={<code>}
686 |code after|={<code>}
687 \end{macrodef}
688
689 The command \macro{\JSONParseArrayMapFunction} accepts \macro{code before} and \macro{code after} as options. These options can be used to place code before and after the output that is generated by the command called for every array item, for example for typesetting tabular contents.
690
691 Typesetting the above example in a tabular way can be achieved as follows:
692
693 \begin{codeexamplecolumns}
694 \newcommand{\myJSONitem}{
695 \JSONParseArrayValueI &
696 \JSONParseArrayValueII \\
697 }
698
699 \JSONParseArrayMapFunction[
700 code before={
701 \begin{tabular}{ c c }
702 \textbf{key a} &
703 \textbf{key b} \\ \hline
704 },
705 code after={
706 \hline
707 \end{tabular}
708 }
709 ]{\myJSONdata}{array}[key_a,key_b]
710 {\myJSONitem}
711 \end{codeexamplecolumns}
712
713 The command \macro{\JSONParseArrayMapFunction} accepts as option set in the first optional argument the key \macro{zero-based} to set the initial value of the mapping counter to the intended value if the key \macro{zero-based} is not set globally.
714
715 Finally, the first optional argument of the command can be used to pass options to the command, such as \macro{escape} or \macro{rescan}, that are then applied locally.
716
717 \begin{macrodef}
718 |\JSONParseArrayMapInline|[<options>]{<token variable>}{<key>}{<inline function>}
719 \end{macrodef}
720 The command \macro{\JSONParseArrayMapInline} takes as first mandatory argument a token variable holding a parsed JSON string or JSON file and as second mandatory argument a key to select an array in the JSON data. The last argument can contain any code where the index of the current item is represented by \macro{#1}. The code may contain another instance of \macro{\JSONParseArrayMapInline}, which means that the command can be nested.
721
722 Using again the above example, the mechanism could be implemented as follows:
723
724 \begin{codeexamplecolumns}
725 \begin{itemize}
726 \JSONParseArrayMapInline{\myJSONdata}
727 {array}{
728 \item \JSONParseValue{\myJSONdata}
729 {array[#1].key_a}
730 }
731 \end{itemize}
732 \end{codeexamplecolumns}
733
734 Making use of the commands \macro{\JSONParseKeys} and \macro{\JSONParseValue} together with the \macro{store in} option, keys and values can be accessed:
735
736 \begin{codeexamplecolumns}
737 \JSONParseArrayMapInline{\myJSONdata}
738 {array}{
739 \JSONParseKeys[store in=\mykeys]
740 {\myJSONdata}{array[#1]}
741 \JSONParseValue
742 [store in=\mykeya, rescan=false]
743 {\mykeys}{[0]}
744 \JSONParseValue
745 [store in=\mykeyb, rescan=false]
746 {\mykeys}{[1]}
747
748 \emph{\mykeya :}
749 \JSONParseValue{\myJSONdata}
750 {array[#1].\mykeya}\par
751
752 \emph{\mykeyb :}
753 \JSONParseValue{\myJSONdata}
754 {array[#1].\mykeyb}\par\bigskip
755 }
756 \end{codeexamplecolumns}
757
758 Note that the underscores in the names of the keys can be printed without changing to math mode in the above example by switching off rescanning via \macro{rescan=false}. This is possible because all JSON data is stored as string where all characters (except for spaces and tabs) have category code 12 (``other'').
759
760 The command \macro{\JSONParseArrayMapInline} accepts as option set in the optional argument the key \macro{store in} which takes a token variable into which the result of the mapped inline function should be stored. Refer to the relevant explanations to command \macro{\JSONParseArrayUse} \hyperlink{macro:arrayuse}{above} for more information.
761
762 The command \macro{\JSONParseArrayMapInline} accepts as option set in the optional argument the key \macro{zero-based} to set the initial value of the mapping counter to the intended value if the key \macro{zero-based} is not set globally.
763
764 \warning In order for the result to be stored in a token variable, the inline function needs to be fully expandable. For example, it is not possible to use the command \macro{\JSONParseValue} in the code of the inline function while using the command \macro{\JSONParseExpandableValue} is allowed. Note that the command \macro{\JSONParseArrayMapInline} itself is not expandable which means that nested use of this command prevents storing the result in a token variable.
765
766 Storing the result of the mapped inline function can be helpful if JSON data should be reformatted for use in a plotting functions. An example for a use case with PGFPlots is shown below. In this example, the parsed JSON string \macro{{ "data": [ [0,0], [1,-1], [2,1] ] }} was stored in the token variable \macro{\myJSONplotdata}.
767
768 \JSONParse{\myJSONplotdata}{ { "data": [ [0,0], [1,-1], [2,1] ] } }
769 \pgfplotsset{width=5.25cm}
770
771 \begin{codeexamplecolumns}
772 \JSONParseArrayMapInline
773 [store in={\myJSONplotcoords}]
774 {\myJSONplotdata}{data}{
775 (
776 \JSONParseExpandableValue
777 {\myJSONplotdata}{data[#1][0]}
778 ,
779 \JSONParseExpandableValue
780 {\myJSONplotdata}{data[#1][1]}
781 )
782 }
783
784 \begin{tikzpicture}
785 \begin{axis}
786 \addplot coordinates
787 {\myJSONplotcoords};
788 \end{axis}
789 \end{tikzpicture}
790 \end{codeexamplecolumns}
791
792 \section{Externalizing parsed JSON data}\label{sec:externalizing}
793
794 Parsing large and complex JSON files can take quite a while. In order to speed up follow-up compilation runs, this package provides a way to store parsed JSON data for future use. Once a file for externalization has been created, the package will try to load the data from this file instead of parsing the JSON data again.
795
796 \begin{macrodef}
797 |externalize|
798 |externalize|={<boolean>}
799 \end{macrodef}
800 With the key \macro{externalize} set (or set to true), a file will be created in the working directory that stores the externalization of the parsed JSON data. The file name gets the extension \macro{.jsonparse}. The file name is created automatically and consists of the name of the current file followed by an underscore and the name of the token variable where the JSON data is stored into. If a file with the same name and file extension already exists, an error will be issued.
801
802 This key can be set using \macro{\JSONParseSet}. It can also be set locally as option to the commands \macro{\JSONParse} and \macro{\JSONParseFromFile}.
803
804 \begin{macrodef}
805 |externalize prefix|={<string>}
806 \end{macrodef}
807 With the key \macro{externalize prefix}, a prefix can be defined that is added to the file name. Per default this is an empty string.
808
809 This key can be set using \macro{\JSONParseSet}. It can also be set locally as option to the commands \macro{\JSONParse} and \macro{\JSONParseFromFile}.
810
811 \begin{macrodef}
812 |externalize file name|={<token list>}
813 \end{macrodef}
814 The key \macro{externalize file name} sets the schema for the file name. The default schema is as follows:
815
816 \begin{codeexample}
817 \l_jsonparse_externalize_prefix_str \c_sys_jobname_str
818 \c_underscore_str \l_jsonparse_current_prop_str
819 \end{codeexample}
820
821 The token variable \macro{\l_jsonparse_externalize_prefix_str} contains the prefix that is set using the key \macro{externalize prefix}. \macro{\c_sys_jobname_str} holds the name of the current file (the current job name), \macro{\c_underscore_str} is an underscore and the token variable \macro{\l_jsonparse_current_prop_str} contains the name of the property list where the relevant JSON data is stored into (without the leading backslash).
822
823 This key can be set using \macro{\JSONParseSet}. It can also be set locally as option to the commands \macro{\JSONParse} and \macro{\JSONParseFromFile}.
824
825 \begin{macrodef}
826 |\JSONParsePut|{<token variable>}{<key>}{<JSON string>}
827 \end{macrodef}
828 The command \macro{\JSONParsePut} is used by the externalization procedure to re-read already parsed JSON data to the main file. It just adds a key-value pair to the property list (where the value part is read as string). Hence, it can also be used to append more entries to an already existing property list containing parsed JSON data.
829
830 \section{Changing parsing and typesetting behavior via option keys}\label{sec:options}
831
832 The package provides a set of keys that can be set to change the separators used to select the relevant value in the JSON structure, the output that is generated from the JSON data as well as other things.
833
834 \begin{macrodef}
835 |\JSONParseSet|{<options>}
836 \end{macrodef}
837 The command \macro{\JSONParseSet} can be used to specify options via key-value pairs (separated by commas). Keys that are presented here as a subkey (i.\,e.\ preceded by another key and a slash such as \macro{key/subkey}) can also be set using the syntax \macro{key={subkey}} and multiple subkeys belonging to one key can be combined using commas as separator. Several user commands allow to pass keys directly which are then applied locally.
838
839 Not every key takes effect in every situation. Some keys affect the parsing procedure and thus need to be set before parsing. Some keys affect the typeset result and some keys only affect the typeset result when used in combination with specific commands.
840
841 \subsection{Keys affecting the parsing procedure}
842
843 Information about the key \macro{externalize} as well as about the related keys \macro{externalize prefix} and \macro{externalize file name} can be found above in section \ref{sec:externalizing}.
844
845 \begin{macrodef}
846 separator/|child|={<string>}
847 separator/|array left|={<string>}
848 separator/|array right|={<string>}
849 \end{macrodef}
850 With the key \macro{separator/child}, the separator for child objects that is used in the key to select a specific value in the JSON data structure can be changed. Per default, the child separator is a dot (\macro{.}).
851
852 With the keys \macro{separator/array left} and \macro{separator/array right}, the separators for arrays that are used in the key to select a specific value in the JSON data structure can be changed. Per default, the separators are square brackets (\macro{[} and \macro{]}). Changing these separators to curly braces (\macro{{}}) is not supported due to their grouping function in TeX.
853
854 Changing the separators can be useful if keys in the JSON structure already use these characters. These settings take place already during parsing.
855
856 These keys can be set using \macro{\JSONParseSet}. They can also be set locally as option to the commands \macro{\JSONParse} and \macro{\JSONParseFromFile}. When set using \macro{\JSONParseSet}, these keys only take effect when set before parsing.
857
858 \begin{macrodef}
859 |zero-based|
860 |zero-based|={<boolean>}
861 \end{macrodef}
862 If the key \macro{zero-based} is set (or explicitly set to \macro{true}), the index of array items starts with zero. If set to false, the indexing starts with one instead. Per default, the package uses zero-based indexing to match JavaScript notation. This setting affects indexing already during parsing.
863
864 This key can be set using \macro{\JSONParseSet}. It can also be set locally as option to the commands \macro{\JSONParse} and \macro{\JSONParseFromFile}. When set using \macro{\JSONParseSet}, this key only takes effect when set before parsing.
865
866 If this key is set locally as option to the command \macro{\JSONParse} or \macro{\JSONParseFromFile}, it is necessary to also set it locally as option to the array-handling commands \macro{\JSONParseArrayUse}, \macro{\JSONParseArrayMapFunction} and \macro{\JSONParseArrayMapInline} to let the relevant mapping function start from the correct value of the internal counter.
867
868 \begin{macrodef}[key:validatenumbers]
869 |validate numbers|
870 |validate numbers|={<boolean>}
871 \end{macrodef}
872 If set to \macro{false}, the key \macro{validate numbers} omits an internal validation of numerical expressions against the JSON specification for numbers. Turning off this feature can increase the parsing speed if many numbers are to be parsed. Validations are carried out per default.
873
874 This key can be set using \macro{\JSONParseSet}. It can also be set locally as option to the commands \macro{\JSONParse} and \macro{\JSONParseFromFile}.
875
876 \begin{macrodef}[key:skipstructures]
877 |skip structures|
878 |skip structures|={<boolean>}
879 \end{macrodef}
880 If set or explicitly set to \macro{true}, the key \macro{skip structures} deactivates the storage of arrays and objects as values to the relative keys. Also, it omits storing of the whole JSON string as value with the pseudo key \macro{.} (or the string defined using the key \macro{separator/child}). Skipping structures is deactivated per default. Setting this key to true can speed up the parsing process and circumvent memory limitations.
881
882 This key can be set using \macro{\JSONParseSet}. It can also be set locally as option to the commands \macro{\JSONParse} and \macro{\JSONParseFromFile}.
883
884 \subsection{Keys affecting the typesetting}
885
886 Some keys that change the typesetting behavior are explained in other parts of this documentation.
887
888 \begin{itemize}
889 \item Information about the keys \macro{escape} and \macro{rescan} can be found above in section \ref{sec:escaping}.
890 \item Information about the key \macro{store in} can be found \hyperlink{key:storein}{above} in the context of the description to the command \macro{\JSONParseValue} as well as in the description to \macro{\JSONParseKeys}, \macro{\JSONParseArrayCount}, \macro{\JSONParseArrayUse} and \macro{\JSONParseArrayMapInline}.
891 \item Information about the keys \macro{code before} and \macro{code after} can be found above in the description to the command \macro{\JSONParseArrayMapFunction} \hyperlink{macro:arraymapfunction}{above}.
892 \end{itemize}
893
894 \begin{macrodef}
895 keyword/|true|={<string>}
896 keyword/|false|={<string>}
897 keyword/|null|={<string>}
898 \end{macrodef}
899 With the keys \macro{keyword/true}, \macro{keyword/false} and \macro{keyword/null}, the string that is typeset for true, false and null values can be changed. The default strings that are typeset are \macro{true}, \macro{false} and \macro{null} respectively. Only strings should be used as replacement. These replacements take place already during parsing.
900
901 These keys can be set using \macro{\JSONParseSet}. They can also be set locally as option to the commands \macro{\JSONParse} and \macro{\JSONParseFromFile}. When set using \macro{\JSONParseSet}, these keys only take effect when set before parsing.
902
903 \begin{macrodef}
904 replace/|backspace|={<token list>}
905 replace/|formfeed|={<token list>}
906 replace/|linefeed|={<token list>}
907 replace/|carriage return|={<token list>}
908 replace/|horizontal tab|={<token list>}
909 \end{macrodef}
910 These keys can be used to set the replacement for the JSON escape sequences \macro{\b} (backspace), \macro{\f} (formfeed), \macro{\n} (linefeed), \macro{\r} (carriage return) and \macro{\t} (horizontal tab). The default replacement is a space in each case. These replacements take place only during typesetting. They only take effect if \macro{rescan} is active.
911
912 \warning Note that commands such as \macro{\par} need to be masked (for example by using a copy created via \macro{\let}) in order to be used as replacement.
913
914 These keys can be set using \macro{\JSONParseSet}. They can also be set locally as option to the commands \macro{\JSONParseValue}, \macro{\JSONParseArrayUse} and \macro{\JSONParseArrayMapFunction}.
915
916 \begin{macrodef}
917 |global|
918 |global|={<boolean>}
919 \end{macrodef}
920 The key \macro{global} can be used together with the key \macro{store in} to globally set the value of the relevant token list. Detailed information about the key \macro{store in} can be found \hyperlink{key:storein}{above}.
921
922 \section{Preparsing via sockets}
923
924 The package provides two sockets \macro{jsonparse/preparse} and \macro{jsonparse/preparse-file} using which the code for the procedure for rescanning the JSON input can be changed. The code provided by the sockets should populate the token list \macro{\g_jsonparse_json_tl} with data that is eventually parsed into the property list for further use.
925
926 Two default plugs are provided and assigned per default for the two sockets. Both sockets require exactly one argument which can be referred to by \macro{#1} in the definition of the plugs. For the socket \macro{jsonparse/preparse} which is used in the command \macro{\JSONParse}, this represents the provided JSON input. For the socket \macro{jsonparse/preparse-file} which is used in the command \macro{\JSONParseFromFile}, this represents the file name. The two default plugs are defined as follows:
927
928 \begin{codeexample}
929 \socket_new_plug:nnn { jsonparse / preparse } { default } {
930 \tl_set:Nn \obeyedline { ~ }
931 \tl_gset_rescan:Nne \g_jsonparse_json_tl {
932 \cctab_select:N \c_jsonparse_json_cctab
933 } {#1}
934 }
935 \end{codeexample}
936
937 \begin{codeexample}
938 \socket_new_plug:nnn { jsonparse / preparse-file } { default } {
939 \file_get:nnN {#1} { \cctab_select:N \c_jsonparse_json_cctab }
940 \g_jsonparse_json_tl
941 }
942 \end{codeexample}
943
944 It is, for example, possible to make use of this mechanism by defining a new plug to parse JSONL data which consists of a number of JSON objects separated by a line break (the two lines with regular expression replacements ensure that no unwanted leading or trailing commas appear in the array):
945
946 \begin{codeexample}
947 \socket_new_plug:nnn { jsonparse / preparse } { jsonl } {
948 \tl_set:Nn \obeyedline { , }
949 \tl_gset_rescan:Nne \g_jsonparse_json_tl {
950 \cctab_select:N \c_jsonparse_json_escape_cctab
951 } { [ #1 ] }
952 \regex_replace_once:nnN { \A\[, } { [ }
953 \g_jsonparse_json_tl
954 \regex_replace_once:nnN { ,\]\Z } { ] }
955 \g_jsonparse_json_tl
956 }
957 \end{codeexample}
958
959 \begin{macrodef}
960 |preparse|={<string>}
961 \end{macrodef}
962 The commands \macro{\JSONParse} and \macro{\JSONParseFromFile} accept the key \macro{preparse} as option. The key takes as argument the name of the plug that will be assigned to the \macro{jsonparse/preparse} or \macro{jsonparse/preparse-file} socket and then used when parsing the relevant JSON string or file.
963
964 To assign the plug for all following calls of \macro{\JSONParse} or \macro{\JSONParseFromFile}, assign the plug use the command \macro{\AssignSocketPlug}. The above defined plug for JSONL for example can be assigned using \macro{\AssignSocketPlug{jsonparse/preparse}{jsonl}}.
965
966 \warning Changing the rescanning procedure via the provided sockets requires in-depth knowledge about how the parsing procedure works. It also requires knowledge about how TeX deals with category codes and control sequences.
967
968 \section{L3 token variables and commands}
969
970 The following token variables and commands are provided for defining user functions by package authors. For the conditional functions described below, apart from the variant that provides a true and a false branch, the two variants that only provide an argument for the true or for the false branch respectively are defined as well which is indicated by the letters {\itshape\macro{TF}} printed in italics. Commands marked with a star (\expandablestar) are fully expandable.
971
972 \begin{macrodef}
973 |\c_jsonparse_json_cctab|
974 \end{macrodef}
975 The token variable \macro{\c_jsonparse_json_cctab} holds the category code table that is used for rescanning JSON input. The definition is as follows:
976
977 \begin{codeexample}
978 \cctab_const:Nn \c_jsonparse_json_cctab {
979 \cctab_select:N \c_str_cctab
980 \char_set_catcode_space:n { 9 }
981 \char_set_catcode_escape:n { 92 }
982 \bool_lazy_or:nnF {
983 \sys_if_engine_xetex_p:
984 } {
985 \sys_if_engine_luatex_p:
986 } {
987 \int_step_function:nnN { 128 } { 255 }
988 \char_set_catcode_active:n
989 }
990 }
991 \end{codeexample}
992
993 \begin{macrodef}
994 |\g_jsonparse_json_tl|
995 \end{macrodef}
996 The token variable \macro{\g_jsonparse_json_tl} holds the rescanned JSON input before it is parsed by the command \macro{\jsonparse_parse:n}.
997
998 \begin{macrodef}
999 |\g_jsonparse_entries_prop|
1000 \end{macrodef}
1001 The token variable \macro{\g_jsonparse_entries_prop} holds as property list all elements of a JSON data structure that was parsed by the command \macro{\jsonparse_parse:n}.
1002
1003 \begin{macrodef}
1004 |\l_jsonparse_current_prop_str|
1005 \end{macrodef}
1006 The token variable \macro{\l_jsonparse_current_prop_str} holds the name of the property list as defined by the user when calling the command \macro{\JSONParse} or \macro{\JSONParseFromFile} (without the leading backslash).
1007
1008 \begin{macrodef}
1009 |\l_jsonparse_externalize_prefix_str|
1010 \end{macrodef}
1011 The token variable \macro{\l_jsonparse_externalize_prefix_str} holds the prefix for externalization file names as defined by the user via the key \macro{externalize prefix}.
1012
1013 \begin{macrodef}
1014 |\jsonparse_parse:n| {<JSON string>}
1015 |\jsonparse_parse:o| {<JSON string>}
1016 |\jsonparse_parse:e| {<JSON string>}
1017 \end{macrodef}
1018 The command \macro{\jsonparse_parse:n} takes as argument a JSON string and populates the token variable (property list) \macro{\g_jsonparse_entries_prop} with key-value pairs representing all elements of the JSON data structure represented by this string. This command does not escape the input in any way.
1019
1020 \begin{macrodef}
1021 |\jsonparse_set_parse:Nn| <token variable> {<JSON string>}
1022 |\jsonparse_set_parse:No| <token variable> {<JSON string>}
1023 |\jsonparse_set_parse:Ne| <token variable> {<JSON string>}
1024 \end{macrodef}
1025 The command \macro{\jsonparse_set_parse:Nn} creates the token variable given as the first arguments as property list and, after having called \macro{\jsonparse_parse:n} using the second argument, locally sets this newly created property list equal to \macro{\g_jsonparse_entries_prop}. If escaping is activated, this command will pre-process the input according to the selected escaping mode before forwarding it to \macro{\jsonparse_parse:n}. See more on escaping above in section \ref{sec:escaping}.
1026
1027 \begin{macrodef}
1028 |\jsonparse_gset_parse:Nn| <token variable> {<JSON string>}
1029 |\jsonparse_gset_parse:No| <token variable> {<JSON string>}
1030 |\jsonparse_gset_parse:Ne| <token variable> {<JSON string>}
1031 \end{macrodef}
1032 The command \macro{\jsonparse_gset_parse:Nn} is identical to \macro{\jsonparse_set_parse:Nn} but with the property list being set globally.
1033
1034 \begin{macrodef}
1035 |\jsonparse_set_parse_keys:NN| <string variable> <token variable>
1036 \end{macrodef}
1037 The command \macro{\jsonparse_set_parse_keys:NN} processes the token variable given as the second argument as property list and selects all top-level keys which are then stored in the string variable given as first argument as JSON array. The pseudo key \macro{.} (or the string defined using the key \macro{separator/child}) to select the complete JSON data is ignored. If the JSON data is an array, the indices of the items (wrapped into the separators defined by \macro{separator/array left} and \macro{separator/array right}) are used as keys.
1038
1039 \begin{macrodef}
1040 |\jsonparse_rescan:n| {<JSON value>}
1041 |\jsonparse_rescan:e| {<JSON value>}
1042 \end{macrodef}
1043 The command \macro{\jsonparse_rescan:n} rescans the JSON value given in the argument. Rescanning converts all tokens to their default category codes and TeX control sequences are expanded. Further, during the rescanning process, JSON escape sequences are replaced and characters that don't require escaping in JSON but in TeX are replaced by the relevant TeX escape sequences.
1044
1045 \begin{macrodef}
1046 |\jsonparse_set_rescan:Nn| <token variable> {<JSON value>}
1047 |\jsonparse_set_rescan:Ne| <token variable> {<JSON value>}
1048 |\jsonparse_set_rescan:cn| {<token variable name>} {<JSON value>}
1049 |\jsonparse_set_rescan:ce| {<token variable name>} {<JSON value>}
1050 \end{macrodef}
1051 The command \macro{\jsonparse_set_rescan:Nn} rescans the JSON value given in the second argument and stores the result locally in the token variable specified in the first argument.
1052
1053 \begin{macrodef}
1054 |\jsonparse_gset_rescan:Nn| <token variable> {<JSON value>}
1055 |\jsonparse_gset_rescan:Ne| <token variable> {<JSON value>}
1056 |\jsonparse_gset_rescan:cn| {<token variable name>} {<JSON value>}
1057 |\jsonparse_gset_rescan:ce| {<token variable name>} {<JSON value>}
1058 \end{macrodef}
1059 The command \macro{\jsonparse_gset_rescan:Nn} rescans the JSON value given in the second argument and stores the result globally in the token variable specified in the first argument.
1060
1061 \begin{macrodef}
1062 |\jsonparse_put_right_rescan:Nn| <token variable> {<JSON value>}
1063 |\jsonparse_put_right_rescan:Ne| <token variable> {<JSON value>}
1064 \end{macrodef}
1065 The command \macro{\jsonparse_put_right_rescan:Nn} rescans the JSON value given in the second argument and adds the result locally to the end of the token variable specified in the first argument.
1066
1067 \begin{macrodef}
1068 |\jsonparse_gput_right_rescan:Nn| <token variable> {<JSON value>}
1069 |\jsonparse_gput_right_rescan:Ne| <token variable> {<JSON value>}
1070 \end{macrodef}
1071 The command \macro{\jsonparse_gput_right_rescan:Nn} rescans the JSON value given in the second argument and adds the result globally to the end of the token variable specified in the first argument.
1072
1073 \begin{macrodef}
1074 |\jsonparse_set_filter:Nn| <token variable> {<key>}
1075 \end{macrodef}
1076 The command \macro{\jsonparse_set_filter:Nn} processes the token variable given as the first argument as property list and filters it according to the key given as second argument. Filtering means that for every entry in the property list, the key of this entry is compared against the key given to the command. If the key in the property list starts with the given key, the matching part is removed from the key in the property list. If the keys do not match, the entry is completely removed from the property list. If the second argument matches the pseudo key \macro{.} (or the string defined using the key \macro{separator/child}) exactly, the complete property list except for this key is returned.
1077
1078 \begin{macrodef}
1079 |\jsonparse_set_array_count:NN| <integer variable> <token variable>
1080 \end{macrodef}
1081 The command \macro{\jsonparse_set_array_count:NN} processes the token variable given as the second argument as property list and, assuming that it is an array, counts its items and stores the result in the integer variable given as first argument. If the token variable does not expand to a key that represents an array item, that is if the key does not start with the character defined by \macro{separator/array left}, the command will return an error.
1082
1083 The command \macro{\JSONParseArrayCount} serves as a wrapper of this command.
1084
1085 \begin{macrodef}*
1086 |\jsonparse_if_num:n|?TF? {<string>} {<true code>} {<false code>}
1087 |\jsonparse_if_num:V|?TF? <string variable> {<true code>} {<false code>}
1088 |\jsonparse_if_num_p:n| {<string>}
1089 |\jsonparse_if_num_p:V| <string variable>
1090 \end{macrodef}
1091 The expandable conditional function \macro{\jsonparse_if_num:nTF} checks whether a string is a valid JSON number according the relevant specification. It executes the true code if the string is a valid JSON number and the false code if not. The variants that only provide an argument for the true or false case work accordingly. The command \macro{\jsonparse_if_num_p:n} returns a boolean true or false (i.\,e.\ \macro{\c_true_bool} or \macro{\c_false_bool}).
1092
1093 \begin{macrodef}*
1094 |\jsonparse_unicode_if_high_surrogate:n|?TF? {<codepoint>}
1095 {<true code>} {<false code>}
1096 |\jsonparse_unicode_if_high_surrogate:e|?TF? {<codepoint>}
1097 {<true code>} {<false code>}
1098 |\jsonparse_unicode_if_high_surrogate_p:n| {<codepoint>}
1099 |\jsonparse_unicode_if_high_surrogate_p:e| {<codepoint>}
1100 \end{macrodef}
1101 The expandable conditional function \macro{\jsonparse_unicode_if_high_surrogate:nTF} checks whether the codepoint entered as argument (an integer that can be hexadecimal if preceded by \macro{"}) is in the range of \macro{"D800} and \macro{"DBFF} which means that it is the first part of a surrogate pair (a high surrogate). The conditional function executes the true or false code depending on the evaluation. The variants that only provide an argument for the true or false case work accordingly. The command \macro{\jsonparse_unicode_if_high_surrogate_p:n} returns a boolean true or false (i.\,e.\ \macro{\c_true_bool} or \macro{\c_false_bool}).
1102
1103 \begin{macrodef}*
1104 |\jsonparse_unicode_if_low_surrogate:n|?TF? {<codepoint>}
1105 {<true code>} {<false code>}
1106 |\jsonparse_unicode_if_low_surrogate:e|?TF? {<codepoint>}
1107 {<true code>} {<false code>}
1108 |\jsonparse_unicode_if_low_surrogate_p:n| {<codepoint>}
1109 |\jsonparse_unicode_if_low_surrogate_p:e| {<codepoint>}
1110 \end{macrodef}
1111 The expandable conditional function \macro{\jsonparse_unicode_if_low_surrogate:nTF} checks whether the codepoint entered as argument (an integer that can be hexadecimal if preceded by \macro{"}) is in the range of \macro{"DC00} and \macro{"DFFF} which means that it is the last part of a surrogate pair (a low surrogate). The conditional function executes the true or false code depending on the evaluation. The variants that only provide an argument for the true or false case work accordingly. The command \macro{\jsonparse_unicode_if_low_surrogate_p:n} returns a boolean true or false (i.\,e.\ \macro{\c_true_bool} or \macro{\c_false_bool}).
1112
1113 \begin{macrodef}*
1114 |\jsonparse_unicode_convert_surrogate_pair:nn| {<codepoint>} {<codepoint>}
1115 |\jsonparse_unicode_convert_surrogate_pair:ee| {<codepoint>} {<codepoint>}
1116 \end{macrodef}
1117 The expandable command \macro{\jsonparse_unicode_convert_surrogate_pair:nn} converts a surrogate pair to the relevant Unicode codepoint. The returned value is an integer. It takes as first argument the codepoint of the low surrogate and as second argument the codepoint of the high surrogate. It does not check whether the codepoints actually belong to the relevant ranges of codepoints for high and low surrogates.
1118
1119 \section{Deprecated commands}
1120
1121 The following commands displayed in red boxes on the left have been deprecated and the relevant replacement displayed in the green box right to it should be used. To simplify the representation of the code and clarify how arguments are supposed to be used, numbers are used to identify the arguments.
1122
1123 To ensure backward compatibility, the deprecated commands are still supported, but their use is not recommended.
1124
1125 \subsection{Deprecated user commands}
1126
1127 \begin{macrodeprecated}*
1128 |\JSONParseSetValue|
1129 {<1>}{<2>}{<3>}
1130 \end{macrodeprecated}
1131 \hfill
1132 \begin{macroreplacement}
1133 |\JSONParseValue|[store in={<1>},
1134 rescan=false]{<2>}{<3>}
1135 \end{macroreplacement}
1136
1137 \begin{macrodeprecated}*
1138 |\JSONParseSetRescanValue|
1139 {<1>}{<2>}{<3>}
1140 \end{macrodeprecated}
1141 \hfill
1142 \begin{macroreplacement}
1143 |\JSONParseValue|[store in={<1>},
1144 rescan]{<2>}{<3>}
1145 \end{macroreplacement}
1146
1147 \begin{macrodeprecated}*
1148 |\JSONParseSetKeys|
1149 {<1>}{<2>}{<3>}
1150 \end{macrodeprecated}
1151 \hfill
1152 \begin{macroreplacement}
1153 |\JSONParseKeys|
1154 [store in={<1>}]{<2>}{<3>}
1155 \end{macroreplacement}
1156
1157 \begin{macrodeprecated}*
1158 |\JSONParseSetArrayCount|
1159 {<1>}{<2>}{<3>}
1160 \end{macrodeprecated}
1161 \hfill
1162 \begin{macroreplacement}
1163 |\JSONParseArrayCount|
1164 [store in={<1>}]{<2>}{<3>}
1165 \end{macroreplacement}
1166
1167 \begin{macrodeprecated}*
1168 |\JSONParseArrayValues|
1169 [<1>]{<2>}{<3>}[<4>]{<5>}
1170 \end{macrodeprecated}
1171 \hfill
1172 \begin{macroreplacement}
1173 |\JSONParseArrayUse|
1174 [<1>]{<2>}{<3>}[<4>]{<5>}
1175 \end{macroreplacement}
1176
1177 \begin{macrodeprecated}*
1178 |\JSONParseArrayValuesMap|
1179 [<1>]{<2>}{<3>}[<4>]{<5>}
1180 [<6>][<7>]
1181 \end{macrodeprecated}
1182 \hfill
1183 \begin{macroreplacement}
1184 |\JSONParseArrayMapFunction|
1185 [<1>, code before={<6>},
1186 code after={<7>}]
1187 {<2>}{<3>}[<4>]{\<5>}
1188 \end{macroreplacement}
1189
1190 \begin{macrodeprecated}*
1191 |\x|{<1>}{<2>}
1192 \end{macrodeprecated}
1193 \hfill
1194 \begin{macroreplacement}
1195 |\$|{<1>}{<2>}
1196 \end{macroreplacement}
1197
1198 The command \macro{\JSONParseArrayMapFunction} takes as last argument a command denoting the relevant mapping function including the preceding backslash, while the deprecated command \macro{\JSONParseArrayValuesMap} required the name of this function without preceding backslash.
1199
1200 The commands \macro{\JSONParseSetRescanValue} and \macro{\JSONParseSetKeys} set the relevant token variable locally.
1201
1202 \subsection{Deprecated L3 commands}
1203
1204 \begin{macrodeprecated}*
1205 |\jsonparse_to_prop:Nn|
1206 <1> {<2>}
1207 \end{macrodeprecated}
1208 \hfill
1209 \begin{macroreplacement}
1210 |\jsonparse_gset_parse:Nn|
1211 <1> {<2>}
1212 \end{macroreplacement}
1213
1214 \begin{macrodeprecated}*
1215 |\jsonparse_to_prop_local:Nn|
1216 <1> {<2>}
1217 \end{macrodeprecated}
1218 \hfill
1219 \begin{macroreplacement}
1220 |\jsonparse_set_parse:Nn|
1221 <1> {<2>}
1222 \end{macroreplacement}
1223
1224 \begin{macrodeprecated}*
1225 |\jsonparse_filter:Nn|
1226 <1> {<2>}
1227 \end{macrodeprecated}
1228 \hfill
1229 \begin{macroreplacement}
1230 |\jsonparse_set_filter:Nn|
1231 <1> {<2>}
1232 \end{macroreplacement}
1233
1234 \begin{macrodeprecated}*
1235 |\jsonparse_parse_keys:NN|
1236 <1> <2>
1237 \end{macrodeprecated}
1238 \hfill
1239 \begin{macroreplacement}
1240 |\jsonparse_set_parse_keys:NN|
1241 <2> <1>
1242 \end{macroreplacement}
1243
1244 \begin{macrodeprecated}*
1245 |\jsonparse_array_count:NN|
1246 <1> <2>
1247 \end{macrodeprecated}
1248 \hfill
1249 \begin{macroreplacement}
1250 |\jsonparse_set_array_count:NN|
1251 <2> <1>
1252 \end{macroreplacement}
1253
1254 Note that the order of the arguments of the commands \macro{\jsonparse_set_parse_keys:NN} is reversed compared to the deprecated command \macro{\jsonparse_parse_keys:NN}. The same holds for the command \macro{\jsonparse_set_array_count:NN} compared to the deprecated command \macro{\jsonparse_array_count:NN}.
1255
1256 % =====
1257
1258 \printchanges
1259
1260 \end{document}
1261
1262 %% End of file `jsonparse-doc.tex`.