texlive[73467] Master/texmf-dist: jsonparse (15jan25)

commits+karl at tug.org commits+karl at tug.org
Wed Jan 15 22:00:14 CET 2025


Revision: 73467
          https://tug.org/svn/texlive?view=revision&revision=73467
Author:   karl
Date:     2025-01-15 22:00:14 +0100 (Wed, 15 Jan 2025)
Log Message:
-----------
jsonparse (15jan25)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/jsonparse/README.md
    trunk/Master/texmf-dist/doc/latex/jsonparse/jason/jason.svg
    trunk/Master/texmf-dist/doc/latex/jsonparse/jason/jason.tex
    trunk/Master/texmf-dist/doc/latex/jsonparse/jsonparse-doc.pdf
    trunk/Master/texmf-dist/doc/latex/jsonparse/jsonparse-doc.tex
    trunk/Master/texmf-dist/tex/latex/jsonparse/jsonparse.sty

Modified: trunk/Master/texmf-dist/doc/latex/jsonparse/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/jsonparse/README.md	2025-01-15 21:00:05 UTC (rev 73466)
+++ trunk/Master/texmf-dist/doc/latex/jsonparse/README.md	2025-01-15 21:00:14 UTC (rev 73467)
@@ -1,4 +1,4 @@
-![Version 0.9.10](https://img.shields.io/badge/version-0.9.10-blue)
+![Version 0.9.11](https://img.shields.io/badge/version-0.9.11-blue)
 
 ![Jason, the JSON parsing horse](https://github.com/jasperhabicht/jsonparse/assets/6378801/ddfddc70-bf5f-4121-ba45-4b9128875d85)
 
@@ -44,6 +44,6 @@
 
 We can store it in the token variable `\myJSONdata` using the command `\JSONParseFromFile{\myJSONdata}{example.json}`. Calling the command `\JSONParseValue{\myJSONdata}{contactPoint[0].telephone}` would then result in the output `+1 (555) 555-1234` (indices are zero-based per default). 
 
-This package including all files is subject to the LPPL 1.3c license. Copyright 2024 Jasper Habicht (mail(at)jasperhabicht.de).
+This package including all files is subject to the LPPL 1.3c license. Copyright 2024–2025 Jasper Habicht (mail(at)jasperhabicht.de).
 
-Jason, the JSON parsing horse: Copyright 2024 Hannah Klöber.
+Jason, the JSON parsing horse: Copyright 2024–2025 Hannah Klöber.

Modified: trunk/Master/texmf-dist/doc/latex/jsonparse/jason/jason.svg
===================================================================
--- trunk/Master/texmf-dist/doc/latex/jsonparse/jason/jason.svg	2025-01-15 21:00:05 UTC (rev 73466)
+++ trunk/Master/texmf-dist/doc/latex/jsonparse/jason/jason.svg	2025-01-15 21:00:14 UTC (rev 73467)
@@ -1,5 +1,4 @@
 <?xml version='1.0' encoding='UTF-8'?>
-<!-- This file was generated by dvisvgm 3.2.2 -->
 <svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width="250px" height="250px" viewBox='-70.503905 -70.50391 452.105105 441.67801'>
 <defs>
 <clipPath id='clip'>

Modified: trunk/Master/texmf-dist/doc/latex/jsonparse/jason/jason.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/jsonparse/jason/jason.tex	2025-01-15 21:00:05 UTC (rev 73466)
+++ trunk/Master/texmf-dist/doc/latex/jsonparse/jason/jason.tex	2025-01-15 21:00:14 UTC (rev 73467)
@@ -1,5 +1,5 @@
 % File: jason/jason.tex
-% Copyright 2024 Jasper Habicht (mail(at)jasperhabicht.de).
+% Copyright 2024-2025 Jasper Habicht (mail(at)jasperhabicht.de).
 %
 % This work may be distributed and/or modified under the
 % conditions of the LaTeX Project Public License version 1.3c,

Modified: trunk/Master/texmf-dist/doc/latex/jsonparse/jsonparse-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/jsonparse/jsonparse-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/jsonparse/jsonparse-doc.tex	2025-01-15 21:00:05 UTC (rev 73466)
+++ trunk/Master/texmf-dist/doc/latex/jsonparse/jsonparse-doc.tex	2025-01-15 21:00:14 UTC (rev 73467)
@@ -1,18 +1,18 @@
-% File: jsonparse-doc.tex 
-% Copyright 2024 Jasper Habicht (mail(at)jasperhabicht.de).
-% 
+% File: jsonparse-doc.tex
+% Copyright 2024-2025 Jasper Habicht (mail(at)jasperhabicht.de).
+%
 % This work may be distributed and/or modified under the
 % conditions of the LaTeX Project Public License version 1.3c,
 % available at http://www.latex-project.org/lppl/.
-% 
+%
 % This file is part of the `jsonparse' package (The Work in LPPL)
 % and all files in that bundle must be distributed together.
-% 
+%
 % This work has the LPPL maintenance status `maintained'.
-% 
+%
 \documentclass[a4paper]{article}
-\def\jsonparsefileversion{0.9.10}
-\def\jsonparsefiledate{10 December 2024}
+\def\jsonparsefileversion{0.9.11}
+\def\jsonparsefiledate{15 January 2025}
 
 \usepackage[T1]{fontenc}
 \usepackage{Alegreya}
@@ -40,7 +40,7 @@
 \tcbuselibrary{listings}
 \lstdefinestyle{jsonparsedocmacro}{
     basicstyle=\small\ttfamily,
-    literate=*{<}{{{\color{black!50}\guilsinglleft}}}1 
+    literate=*{<}{{{\color{black!50}\guilsinglleft}}}1
         {>}{{{\color{black!50}\guilsinglright}}}1,
     keywords={},
     moredelim=[is][\bfseries]{|}{|},
@@ -57,13 +57,13 @@
 \int_new:N \l_jsonparse_doc_change_int
 \NewDocumentCommand{\changes}{ m m m }{
     \int_incr:N \l_jsonparse_doc_change_int
-    \prop_new:c { l_jsonparse_doc_change_ 
+    \prop_new:c { l_jsonparse_doc_change_
         \int_to_roman:n { \l_jsonparse_doc_change_int } _prop }
-    \prop_put:cnn { l_jsonparse_doc_change_ 
+    \prop_put:cnn { l_jsonparse_doc_change_
         \int_to_roman:n { \l_jsonparse_doc_change_int } _prop } { version } {#1}
-    \prop_put:cnn { l_jsonparse_doc_change_ 
+    \prop_put:cnn { l_jsonparse_doc_change_
         \int_to_roman:n { \l_jsonparse_doc_change_int } _prop } { date } {#2}
-    \prop_put:cnn { l_jsonparse_doc_change_ 
+    \prop_put:cnn { l_jsonparse_doc_change_
         \int_to_roman:n { \l_jsonparse_doc_change_int } _prop } { changes } {#3}
 }
 \NewDocumentCommand{\printchanges}{ }{
@@ -70,13 +70,15 @@
     \section{Changes}
     \begin{description}
     \int_step_inline:nn { \l_jsonparse_doc_change_int } {
-        \item[ 
-            \prop_item:cn { l_jsonparse_doc_change_ 
-            \int_to_roman:n { ##1 } _prop } { version } ] 
-            ( \prop_item:cn { l_jsonparse_doc_change_ 
-            \int_to_roman:n { ##1 } _prop } { date } ) \\
-            \prop_item:cn { l_jsonparse_doc_change_ 
-            \int_to_roman:n { ##1 } _prop } { changes }
+        \item[
+            \prop_item:cn { l_jsonparse_doc_change_
+            \int_to_roman:n { ##1 } _prop } { version }
+        ] (
+            \prop_item:cn { l_jsonparse_doc_change_
+            \int_to_roman:n { ##1 } _prop } { date }
+        ) \\
+        \prop_item:cn { l_jsonparse_doc_change_
+        \int_to_roman:n { ##1 } _prop } { changes }
     }
     \end{description}
 }
@@ -123,7 +125,7 @@
     title style hook/.style={}
 }
 
-\NewTCBListing{macrodef}{ }{ 
+\NewTCBListing{macrodef}{ }{
     listing only,
     listing style={jsonparsedocmacro},
     grow to left by=2cm,
@@ -149,9 +151,9 @@
     size=tight,
     arc=1pt,
     outer arc=1pt,
-    top=0.5pt, 
+    top=0.5pt,
     bottom=0.5pt,
-    left=2pt, 
+    left=2pt,
     right=2pt,
     boxrule=0pt,
     colframe=black!10,
@@ -165,9 +167,9 @@
     size=tight,
     arc=1pt,
     outer arc=1pt,
-    top=0.5pt, 
+    top=0.5pt,
     bottom=0.5pt,
-    left=2pt, 
+    left=2pt,
     right=2pt,
     boxrule=0pt,
     colframe=black!10,
@@ -206,8 +208,9 @@
 \changes{v0.9.5}{2024/10/27}{Streamlining of code, clarification of explanations in documentation.}
 \changes{v0.9.6}{2024/10/31}{Allowing for multiple return values when mapping over arrays.}
 \changes{v0.9.7}{2024/11/05}{Streamlining of code, ensuring backward compatibility.}
-\changes{v0.9.8}{2024/11/19}{Bug fixes, adding possibility to store value in token list.}
-\changes{v0.9.10}{2024/12/10}{Enhanced backward compatibility; switch to linked property lists.}
+\changes{v0.9.8}{2024/11/19}{Bug fixes; adding possibility to store value in token list.}
+\changes{v0.9.10}{2024/12/10}{Enhanced backward compatibility; switching to linked property lists.}
+\changes{v0.9.11}{2025/01/15}{Bug fixes; adding additional command to loop over arrays.}
 
 \begin{document}
 \vspace*{-1cm}
@@ -227,7 +230,7 @@
 
 \section{Loading the package}
 
-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. 
+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.
 
 The package does not load any dependencies.
 
@@ -240,15 +243,15 @@
 
 \section{General remarks of the parsing procedure}
 
-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''). 
+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'').
 
 \section{Escaping and special treatment of the input}\label{sec:escaping}
 
-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 redefines 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 first defined as \macro{\exp_not:N \"} and only when typeset, \macro{\"} is expanded to \macro{"}, which ensures that strings are parsed properly. 
+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 redefines 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 first defined as \macro{\exp_not:N \"} and only when typeset, \macro{\"} is expanded to \macro{"}, which ensures that strings are parsed properly.
 
 Similarly, the control symbol \macro{\/} expands eventually to \macro{/} and \macro{\\} to \macro{\c_backslash_str} (i.\,e. a backslash with category code 12). The escape sequence \macro{\u} followed by a hex value consisting of four digits eventually expands to \macro{\char"} followed by the relevant four hex digits. 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{replacement} key. See more on setting options below in section \ref{sec:options}.
 
-It is possible to insert TeX macros to the JSON source that will eventually be parsed when typesetting. Backslashes of TeX macros need to be escaped by another backslash. The TeX macros \macro{\"} and \macro{\\} must be escaped twice in the JSON source so that they become \macro{\\\"} and \macro{\\\\} respectively. 
+It is possible to insert TeX macros to the JSON source that will eventually be parsed when typesetting. Backslashes of TeX macros need to be escaped by another backslash. The TeX macros \macro{\"} and \macro{\\} must be escaped twice in the JSON source so that they become \macro{\\\"} and \macro{\\\\} respectively.
 
 \begin{macrodef}
 |\x|{<token variable name>}{<key>}
@@ -256,12 +259,12 @@
 Using the control sequence \macro{\x}, it is possible to nest JSON strings into each other. 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:
 
 \begin{codeexamplecolumns}
-    \JSONParse{\myJSONdataA}{ 
-        { "a" : { "b" : "c" } } 
+    \JSONParse{\myJSONdataA}{
+        { "a" : { "b" : "c" } }
     }
 
-    \JSONParse{\myJSONdataB}{ 
-        { "d" : \x{myJSONdataA}{a} } 
+    \JSONParse{\myJSONdataB}{
+        { "d" : \x{myJSONdataA}{a} }
     }
 
     \JSONParseValue{\myJSONdataB}{d.b}
@@ -280,7 +283,7 @@
 |escape|={low line}
 |escape|={tilde}
 \end{macrodef}
-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 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. 
+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 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.
 
 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}.
 
@@ -299,11 +302,11 @@
 \begin{macrodef}
 |\JSONParse|[<options>]{<token variable>}{<JSON string>}
 \end{macrodef}
-The command \macro{\JSONParse} is used to parse a JSON string and store the parsed result in a token variable (a property list). The second argument takes the name of the token variable that is created by the command. The third argument takes the JSON string to be parsed. 
+The command \macro{\JSONParse} is used to parse a JSON string and store the parsed result in a token variable (a property list). The second argument takes the name of the token variable that is created by the command. The third argument takes the JSON string to be parsed.
 
-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 one entry with the key \macro{key} and the value \macro{value}. The command \macro{\JSONParseValue{\myJSONdata}{key}}, for example, can then be used to extract the relevant value from this property list (see the description below). 
+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 one entry with the key \macro{key} and the value \macro{value}. The command \macro{\JSONParseValue{\myJSONdata}{key}}, for example, can then be used to extract the relevant value from this property list (see the description below).
 
-The first optional argument can be used to pass options to the command that are then applied locally. 
+The first optional argument can be used to pass options to the command that are then applied locally.
 
 \begin{macrodef}
 |\JSONParseFromFile|[<options>]{<token variable>}{<JSON file>}
@@ -326,7 +329,7 @@
 
 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. 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 behaviour. If rescanning is not desired, pass the option \macro{rescan=false} to the command.
 
-When a key is associated with an object or array, the whole object or array is output as JSON string. The special key \macro{.} (or the string defined using the key \macro{child sep}) returns the whole JSON object as string. 
+When a key is associated with an object or array, the whole object or array is output as JSON string. The special key \macro{.} (or the string defined using the key \macro{child sep}) returns the whole JSON object as string.
 
 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.
 
@@ -333,14 +336,14 @@
 \begin{macrodef}
 |\JSONParseExpandableValue|{<token variable>}{<key>}
 \end{macrodef}
-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. 
+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.
 
-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 expand to the exact same token list as \macro{\detokenize{value}} with all characters having category code 12 (``other''). 
+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 expand to the exact same token list as \macro{\detokenize{value}} with all characters having category code 12 (``other'').
 
 \begin{macrodef}
 |\JSONParseSetValue|{<token variable>}{<token variable>}{<key>}
 \end{macrodef}
-The command \macro{\JSONParseValueSet} can be used to a select a value from the token variable that stores the parsed JSON data via a key and store this value globally in another token variable. 
+The command \macro{\JSONParseValueSet} can be used to a select a value from the token variable that stores the parsed JSON data via a key and store this value globally in another token variable.
 
 The first argument denotes the token variable where the value should be stored into. If this token variable has not yet been defined, it will be created by this command. The second argument represents the token variable (property list) that has been created using the commands \macro{\JSONParse} or \macro{\JSONParseFromFile} and that stores the parsed JSON data. The third argument takes the key to select the relevant value.
 
@@ -383,9 +386,9 @@
 \end{codeexample}
 \JSONParse{\myJSONdata}{ { "array" : [ { "key_a" : "one" , "key_b" : "two" } , { "key_a" : "three" , "key_b" : "four" } ] } }
 
-Then, when using \macro{\JSONParseArrayValues{\myJSONdata}{array}[key_a]{, }}, `\JSONParseArrayValues{\myJSONdata}{array}[key_a]{, }' is typeset to the document. 
+Then, when using \macro{\JSONParseArrayValues{\myJSONdata}{array}[key_a]{, }}, `\JSONParseArrayValues{\myJSONdata}{array}[key_a]{, }' is typeset to the document.
 
-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. 
+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.
 
 \begin{macrodef}
 |\JSONParseArrayValuesMap|[<options>]{<token variable>}{<key>}[<subkey>]
@@ -412,7 +415,7 @@
 
 \begin{codeexamplecolumns}
 \newcommand{\myJSONitem}{
-  \item \emph{\JSONParseArrayValueI :} 
+  \item \emph{\JSONParseArrayValueI :}
     \JSONParseArrayValueII
 }
 
@@ -422,7 +425,7 @@
 \end{itemize}
 \end{codeexamplecolumns}
 
-The command additionally takes two optional arguments at sixth and seventh position. These arguments 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. 
+The command additionally takes two optional arguments at sixth and seventh position. These arguments 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.
 
 Typesetting the above example in a tabular way can be achieved as follows:
 
@@ -435,27 +438,49 @@
 \JSONParseArrayValuesMap{\myJSONdata}
   {array}[key_a,key_b]{myJSONitem}
   [\begin{tabular}{ c c }
-    \textbf{key a} & 
+    \textbf{key a} &
     \textbf{key b} \\ \hline]
   [\hline \end{tabular}]
 \end{codeexamplecolumns}
 
-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. 
+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.
 
 \begin{macrodef}
 |\JSONParseArrayCount|{<token variable>}{<key>}
 \end{macrodef}
-The command \macro{\JSONParseArrayCount} takes as first argument a token variable holding a parsed JSON string or JSON file and as second argument a key. It returns an integer representing the number of items contained in the selected array.
+The command \macro{\JSONParseArrayCount} takes as first argument a token variable holding a parsed JSON string or JSON file and as second 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.
 
+\begin{macrodef}
+|\JSONParseSetArrayCount|{<token variable>}{<token variable>}{<key>}
+\end{macrodef}
+The command \macro{\JSONParseSetArrayCount} takes as second argument a token variable holding a parsed JSON string or JSON file and as third argument a key to select an array in the JSON data. It stores the number of items contained in the selected array in the token variable given in the first argument of the command.
+
+\begin{macrodef}
+|\JSONParseArrayMapInline|{<token variable>}{<key>}{<inline function>}
+\end{macrodef}
+The command \macro{\JSONParseArrayMapInline} takes as first argument a token variable holding a parsed JSON string or JSON file and as second argument a key to select an array in the JSON data. The third parameter can contain any code where the index of the current item is represented by \macro{#1}.
+
+Using the above example, the mechanism could be implemented as follows:
+
+\begin{codeexamplecolumns}
+\begin{itemize}
+  \JSONParseArrayMapInline{\myJSONdata}
+    {array}{
+    \item \JSONParseValue{\myJSONdata}
+      {array[#1].key_a}
+  }
+\end{itemize}
+\end{codeexamplecolumns}
+
 \subsection{Externalising parsed JSON data}\label{sec:externalizing}
 
-Parsing large 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. 
+Parsing large 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.
 
 \begin{macrodef}
 |externalize|
 |externalize|={<boolean>}
 \end{macrodef}
-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. 
+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.
 
 This key can be set using \macro{\JSONParseSet}. It can also be set locally as option to the commands \macro{\JSONParse} and \macro{\JSONParseFromFile}.
 
@@ -472,7 +497,7 @@
 The key \macro{externalize file name} sets the schema for the file name. The default schema is as follows:
 
 \begin{codeexample}
-\l_jsonparse_externalize_prefix_str \c_sys_jobname_str 
+\l_jsonparse_externalize_prefix_str \c_sys_jobname_str
     \c_underscore_str \l_jsonparse_current_prop_str
 \end{codeexample}
 
@@ -499,9 +524,9 @@
 separator/|array left|={<string>}
 separator/|array right|={<string>}
 \end{macrodef}
-With the key \macro{separator/child}, the separator for child objects that is used in the syntax to select a specific value in the JSON data structure can be changed. Per default, the child separator is a dot (\macro{.}). Changing the separator can be useful if keys in the JSON structure already use these characters. 
+With the key \macro{separator/child}, the separator for child objects that is used in the syntax to select a specific value in the JSON data structure can be changed. Per default, the child separator is a dot (\macro{.}). Changing the separator can be useful if keys in the JSON structure already use these characters.
 
-With the keys \macro{separator/array left} and \macro{separator/array right}, the separators for arrays that are used in the syntax to select a specific value in the JSON data structure can be changed. Per default, the separators are square brackets (\macro{[} and \macro{]}). Changing the separators can be useful if keys in the JSON structure already use these characters. Changing these separators to curly braces (\macro{{}}) is not supported due to their grouping function in TeX. 
+With the keys \macro{separator/array left} and \macro{separator/array right}, the separators for arrays that are used in the syntax to select a specific value in the JSON data structure can be changed. Per default, the separators are square brackets (\macro{[} and \macro{]}). Changing the separators can be useful if keys in the JSON structure already use these characters. Changing these separators to curly braces (\macro{{}}) is not supported due to their grouping function in TeX.
 
 These keys can be set using \macro{\JSONParseSet}. They can also be set locally as option to the commands \macro{\JSONParse} and \macro{\JSONParseFromFile}.
 
@@ -511,7 +536,7 @@
 \end{macrodef}
 If set (or explicitly set to \macro{true}), the key \macro{zero-based} sets the numbering of the index of array items to zero-based. If set to false, the indexing starts with one instead. Per default, the package uses zero-based indexing to resemble JavaScript notation.
 
-This key can be set using \macro{\JSONParseSet}. It can also be set locally as option to the commands \macro{\JSONParse} and \macro{\JSONParseFromFile}.
+This key can be set using \macro{\JSONParseSet}. It can also be set locally as option to the commands \macro{\JSONParse} and \macro{\JSONParseFromFile}. 
 
 \begin{macrodef}
 replace/|true|={<string>}
@@ -539,7 +564,7 @@
 If set to \macro{false}, the key \macro{check num} omits an internal check of numerical expressions against the JSON specification for numbers. Turning off this feature can increase the parsing speed.
 
 This key can be set using \macro{\JSONParseSet}. It can also be set locally as option to the commands \macro{\JSONParse} and \macro{\JSONParseFromFile}.
-    
+
 \subsection{L3 commands}
 
 \begin{macrodef}
@@ -546,16 +571,16 @@
 |\jsonparse_parse:n| {<JSON string>}
 \end{macrodef}
 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.
-  
+
 \begin{macrodef}
 |\jsonparse_parse_to_prop:Nn| <token variable> {<JSON string>}
 \end{macrodef}
-The command \macro{\jsonparse_parse_to_prop: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, 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}. 
+The command \macro{\jsonparse_parse_to_prop: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, 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}.
 
 \begin{macrodef}
 |\jsonparse_filter:Nn| <token variable> {<key>}
 \end{macrodef}
-The command \macro{\jsonparse_parse_to_prop:Nn} processes the token variable given as the first arguments 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. 
+The command \macro{\jsonparse_parse_to_prop:Nn} processes the token variable given as the first arguments 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.
 
 \begin{macrodef}
 |\jsonparse_array_count:NN| <token variable> <integer variable>
@@ -564,7 +589,7 @@
 
 \begin{macrodef}
 |\jsonparse_if_num:nTF| {<string>} {<true code>} {<false code>}
-|\jsonparse_if_num:nT| {<string>} {<true code>} 
+|\jsonparse_if_num:nT| {<string>} {<true code>}
 |\jsonparse_if_num:nF| {<string>} {<false code>}
 |\jsonparse_if_num_p:n| {<string>}
 \end{macrodef}

Modified: trunk/Master/texmf-dist/tex/latex/jsonparse/jsonparse.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/jsonparse/jsonparse.sty	2025-01-15 21:00:05 UTC (rev 73466)
+++ trunk/Master/texmf-dist/tex/latex/jsonparse/jsonparse.sty	2025-01-15 21:00:14 UTC (rev 73467)
@@ -1,5 +1,5 @@
 % File: jsonparse.sty
-% Copyright 2024 Jasper Habicht (mail(at)jasperhabicht.de).
+% Copyright 2024-2025 Jasper Habicht (mail(at)jasperhabicht.de).
 %
 % This work may be distributed and/or modified under the
 % conditions of the LaTeX Project Public License version 1.3c,
@@ -10,15 +10,15 @@
 %
 % This work has the LPPL maintenance status `maintained'.
 %
-\ProvidesExplPackage {jsonparse} {2024-12-10} {0.9.10}
+\ProvidesExplPackage {jsonparse} {2025-01-15} {0.9.11}
   {A handy way to parse, store and access JSON data from files or strings in LaTeX documents}
 
 \msg_new:nnn { jsonparse } { old-kernel } {
   LaTeX ~ kernel ~ too ~ old. \iow_newline:
-  The ~ jsonparse ~ package ~ does ~ not ~ support ~ this ~ LaTeX ~ version. \iow_newline: 
-  Please ~ update ~ to ~ a ~ newer ~ version. 
+  The ~ jsonparse ~ package ~ does ~ not ~ support ~ this ~ LaTeX ~ version. \iow_newline:
+  Please ~ update ~ to ~ a ~ newer ~ version.
 }
-  
+
 \cs_if_exist:NF \ProcessKeyOptions {
   \msg_critical:nn { jsonparse } { old-kernel }
 }
@@ -30,7 +30,7 @@
 \keys_define:nn { jsonparse / global } {
   debug   .bool_set:N = \l__jsonparse_debug_mode_bool ,
   debug   .default:n  = { true } ,
-  debug   .initial:n  = { false } 
+  debug   .initial:n  = { false }
 }
 \ProcessKeyOptions [ jsonparse / global ]
 
@@ -262,6 +262,7 @@
 \cs_generate_variant:Nn \str_casefold:n { o }
 \cs_generate_variant:Nn \str_head_ignore_spaces:n { o }
 \cs_generate_variant:Nn \str_set:Nn { Ne }
+\cs_generate_variant:Nn \int_step_inline:nnn { nVn }
 \cs_generate_variant:Nn \clist_const:Nn { Ne }
 \cs_generate_variant:Nn \seq_put_right:Nn { Ne }
 \cs_generate_variant:Nn \prop_gput:Nnn { Nee }
@@ -327,7 +328,7 @@
 \tl_new:N \l__jsonparse_array_keys_index_roman_tl
 
 \str_new:N \l__jsonparse_array_values_key_str
-\tl_new:N \l__jsonparse_array_values_insert_tl 
+\tl_new:N \l__jsonparse_array_values_insert_tl
 
 \clist_new:N \l__jsonparse_array_map_keys_clist
 \str_new:N \l__jsonparse_array_map_function_str
@@ -374,7 +375,7 @@
   \tl_to_str:n { E }
 }
 
-\clist_concat:NNN \c__jsonparse_num_others_clist 
+\clist_concat:NNN \c__jsonparse_num_others_clist
   \c__jsonparse_num_plus_minus_fraction_clist
   \c__jsonparse_num_exponent_clist
 
@@ -834,20 +835,20 @@
 
 \cs_new:Npn \__jsonparse_filter:nn #1#2 {
   \str_case_e:en {
-    \tl_range:nne {#1} { 1 } { \int_eval:n { 
-      \tl_count:o { \l__jsonparse_filter_key_str } + 1 
+    \tl_range:nne {#1} { 1 } { \int_eval:n {
+      \tl_count:o { \l__jsonparse_filter_key_str } + 1
     } }
   } {
     { \l__jsonparse_filter_key_str \l__jsonparse_child_sep_str } {
       \prop_put:Nen \l__jsonparse_temp_prop
-        { \tl_range:nen {#1} { \int_eval:n { 
-          \tl_count:o { \l__jsonparse_filter_key_str } + 2 
+        { \tl_range:nen {#1} { \int_eval:n {
+          \tl_count:o { \l__jsonparse_filter_key_str } + 2
         } } { -1 } } {#2}
     }
     { \l__jsonparse_filter_key_str \l__jsonparse_array_sep_left_str } {
       \prop_put:Nen \l__jsonparse_temp_prop
-        { \tl_range:nen {#1} { \int_eval:n { 
-          \tl_count:o { \l__jsonparse_filter_key_str } + 1 
+        { \tl_range:nen {#1} { \int_eval:n {
+          \tl_count:o { \l__jsonparse_filter_key_str } + 1
         } } { -1 } } {#2}
     }
   }
@@ -892,12 +893,12 @@
 
 % ===
 
-\cs_new:Npn \__json_nested_construct_cs:Nnn #1#2#3 {
+\cs_new:Npn \__jsonparse_nested_construct_cs:Nnn #1#2#3 {
   \cs_set:Npn #1 #2 ##1 #3 #2 ##2 #3 {
     \prop_item:ce {##1} {##2}
   }
 }
-\cs_generate_variant:Nn \__json_nested_construct_cs:Nnn { Noo }
+\cs_generate_variant:Nn \__jsonparse_nested_construct_cs:Nnn { Noo }
 
 \NewDocumentCommand { \JSONParse } { O{} m +v } {
   \group_begin:
@@ -932,7 +933,7 @@
         \cs_set:Npn \r { \exp_not:N \r }
         \cs_set:Npn \t { \exp_not:N \t }
         \cs_set:Npn \u { \exp_not:N \u }
-        \__json_nested_construct_cs:Noo \x \c_left_brace_str \c_right_brace_str
+        \__jsonparse_nested_construct_cs:Noo \x \c_left_brace_str \c_right_brace_str
         \tl_set:Nn \obeyedline { ~ }
         \tl_gset_rescan:Nne \g__jsonparse_json_tl { \cctab_select:N \c__jsonparse_json_escape_cctab } {#3}
         \exp_args:NNe \jsonparse_parse_to_prop:Nn #2 { \g__jsonparse_json_tl }
@@ -967,7 +968,7 @@
     } {
       \bool_if:NTF \l__jsonparse_compat_bool {
         \prop_new:N #2
-      } { 
+      } {
         \prop_new_linked:N #2
       }
       \tl_gclear:N \g__jsonparse_json_tl
@@ -1137,6 +1138,19 @@
   \group_end:
 }
 
+\NewDocumentCommand { \JSONParseSetArrayCount } { m m m } {
+  \tl_if_exist:NF #1 {
+    \tl_new:N #1
+  }
+  \group_begin:
+    \tl_set_eq:NN \l__jsonparse_temp_tl #2
+    \jsonparse_filter:Nn \l__jsonparse_temp_tl {#3}
+    \jsonparse_array_count:NN \l__jsonparse_temp_tl \l__jsonparse_array_count_int
+    \exp_last_unbraced:Nf
+  \group_end:
+  \tl_set:NV #1 \l__jsonparse_array_count_int
+}
+
 \cs_new:Npn \__jsonparse_array_values:n #1 {
   \bool_if:NTF \l__jsonparse_prop_map_first_bool {
     \bool_set_false:N \l__jsonparse_prop_map_first_bool
@@ -1265,7 +1279,7 @@
     }
   } {
     \int_zero:N \l__jsonparse_array_keys_index_int
-    \clist_map_function:NN \l__jsonparse_array_map_keys_clist 
+    \clist_map_function:NN \l__jsonparse_array_map_keys_clist
       \__jsonparse_array_values_map_keys:n
     \tl_gset_eq:NN \JSONParseArrayKey \JSONParseArrayKeyI
     \tl_gset_eq:NN \JSONParseArrayValue \JSONParseArrayValueI
@@ -1301,10 +1315,25 @@
         \__jsonparse_array_map_generate_cs:n
     }
     #6
-    \int_step_function:nN { \l__jsonparse_array_count_int } 
-      \__jsonparse_array_values_map:n 
+    \int_step_function:nN { \l__jsonparse_array_count_int }
+      \__jsonparse_array_values_map:n
     #7
   \group_end:
 }
 
+\NewDocumentCommand { \JSONParseArrayMapInline } { m m m } {
+  \group_begin:
+    \tl_set_eq:NN \l__jsonparse_temp_tl #1
+    \jsonparse_filter:Nn \l__jsonparse_temp_tl {#2}
+    \jsonparse_array_count:NN \l__jsonparse_temp_tl \l__jsonparse_array_count_int
+    \bool_if:NT \l__jsonparse_zero_based_bool {
+      \int_decr:N \l__jsonparse_array_count_int
+    }
+    \exp_last_unbraced:Nf
+  \group_end:
+  \int_step_inline:nVn {
+    \bool_if:NTF \l__jsonparse_zero_based_bool { 0 } { 1 }
+  } \l__jsonparse_array_count_int {#3}
+}
+
 % ===



More information about the tex-live-commits mailing list.