texlive[74734] Master/texmf-dist: jsonparse (24mar25)
commits+karl at tug.org
commits+karl at tug.org
Mon Mar 24 20:46:57 CET 2025
Revision: 74734
https://tug.org/svn/texlive?view=revision&revision=74734
Author: karl
Date: 2025-03-24 20:46:57 +0100 (Mon, 24 Mar 2025)
Log Message:
-----------
jsonparse (24mar25)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/jsonparse/README.md
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-03-24 19:46:48 UTC (rev 74733)
+++ trunk/Master/texmf-dist/doc/latex/jsonparse/README.md 2025-03-24 19:46:57 UTC (rev 74734)
@@ -1,4 +1,4 @@
-
+

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-03-24 19:46:48 UTC (rev 74733)
+++ trunk/Master/texmf-dist/doc/latex/jsonparse/jsonparse-doc.tex 2025-03-24 19:46:57 UTC (rev 74734)
@@ -11,8 +11,8 @@
% This work has the LPPL maintenance status `maintained'.
%
\documentclass[a4paper]{article}
-\def\jsonparsefileversion{1.2.1}
-\def\jsonparsefiledate{24 February 2025}
+\def\jsonparsefileversion{1.2.3}
+\def\jsonparsefiledate{23 March 2025}
\usepackage[T1]{fontenc}
\usepackage{Alegreya}
@@ -230,40 +230,42 @@
{Jasper Habicht}[E-mail: \href{mailto:mail at jasperhabicht.de}{mail at jasperhabicht.de}. 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--2025 Hannah Klöber.]
{Version \jsonparsefileversion, released on \jsonparsefiledate}
-\changes{v0.3.0}{2024/04/08}{First public beta release.}
+%\changes{v0.3.0}{2024/04/08}{First public beta release.}
\changes{v0.5.0}{2024/04/09}{Changed from string token variables to token lists to support Unicode.}
-\changes{v0.5.5}{2024/04/09}{Bug fixes, introduction and enhancement of user functions.}
+%\changes{v0.5.5}{2024/04/09}{Bug fixes, introduction and enhancement of user functions.}
\changes{v0.5.6}{2024/04/11}{Bug fixes, escaping of special chars added.}
\changes{v0.5.7}{2024/04/14}{Bug fixes, key-value option setting added.}
-\changes{v0.6.0}{2024/04/15}{Bug fixes, renaming of several commands.}
+%\changes{v0.6.0}{2024/04/15}{Bug fixes, renaming of several commands.}
\changes{v0.7.0}{2024/04/18}{Renaming and rearranging of keys, escaping of special JSON escape sequences added.}
\changes{v0.7.1}{2024/04/20}{Access to top-level keys of object added.}
\changes{v0.8.0}{2024/04/24}{Internal rewrite, escaping procedures changed.}
\changes{v0.8.2}{2024/04/26}{Bug fixes, externalizing parsed data.}
\changes{v0.8.3}{2024/04/28}{Escaping of characters with special meaning in TeX.}
-\changes{v0.8.5}{2024/05/05}{Enhanced key management.}
-\changes{v0.8.6}{2024/05/09}{Bug fix in nesting function.}
-\changes{v0.8.7}{2024/08/08}{Corrections in documentation, error messages.}
+%\changes{v0.8.5}{2024/05/05}{Enhanced key management.}
+%\changes{v0.8.6}{2024/05/09}{Bug fix in nesting function.}
+%\changes{v0.8.7}{2024/08/08}{Corrections in documentation, error messages.}
\changes{v0.9.0}{2024/08/27}{Adaption to updated verbatim tokenization.}
\changes{v0.9.1}{2024/09/21}{Added functions to test for valid JSON numbers.}
\changes{v0.9.3}{2024/10/24}{Fixed a bug that prevented tabs in source from being parsed properly.}
-\changes{v0.9.5}{2024/10/27}{Streamlining of code, clarification of explanations in documentation.}
+%\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.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; switching to linked property lists.}
-\changes{v0.9.11}{2025/01/15}{Bug fixes; adding additional command to loop through arrays.}
+%\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 through arrays.}
\changes{v0.9.12}{2025/01/17}{Bug fixes; adding commands to access items in arrays.}
-\changes{v1.0.0}{2025/01/20}{Streamlining of code, unification of command structure.}
+%\changes{v1.0.0}{2025/01/20}{Streamlining of code, unification of command structure.}
\changes{v1.0.1}{2025/01/21}{Fixes in documentation. Added user command for filtering.}
\changes{v1.0.2}{2025/01/23}{Support for Unicode surrogate pairs.}
-\changes{v1.0.3}{2025/01/26}{Test for valid JSON numbers expandable.}
+%\changes{v1.0.3}{2025/01/26}{Test for valid JSON numbers expandable.}
\changes{v1.1.0}{2025/01/30}{Unified names of user functions; renaming key for keywords.}
\changes{v1.1.1}{2025/02/03}{Added option to store result of mapped inline function.}
\changes{v1.1.2}{2025/02/08}{Added option to store result of array function.}
-\changes{v1.1.3}{2025/02/13}{Bug fixes.}
-\changes{v1.2.0}{2025/02/22}{Unified option to store result.}
+%\changes{v1.1.3}{2025/02/13}{Bug fixes.}
+%\changes{v1.2.0}{2025/02/22}{Unified option to store result.}
\changes{v1.2.1}{2025/02/24}{Unified functions, added option to store result globally.}
+%\changes{v1.2.2}{2025/02/25}{Fixes in documentation.}
+\changes{v1.2.3}{2025/03/23}{Enabled nesting of mapped inline function.}
\begin{document}
\vspace*{-1cm}
@@ -376,7 +378,7 @@
\end{macrodef}
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.
-\begin{macrodef}[macro:parsevalue]
+\begin{macrodef}
|\JSONParseValue|[<options>]{<token variable>}{<key>}
\end{macrodef}
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 second argument 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.
@@ -385,22 +387,22 @@
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" ] }}.
-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.
+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 behavior. 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 (or the whole JSON array if the JSON daza only cosists of one array) as string where all characters (except for spaces and tabs) have category code 12 (``other'').
+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 (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'').
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.
-\begin{macrodef}
+\begin{macrodef}[key:storein]
|store in|={<token variable>}
\end{macrodef}
-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.
+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.
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'').
-The key \macro{store in} can be used together with the key \macro{rescan} to rescans 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.
+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.
-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 recognised 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:
+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:
\JSONParse{\myJSONnumber}{ { "number" : -1.1e-1 } }
\begin{codeexamplecolumns}
@@ -410,6 +412,8 @@
\num{\mynumber}
\end{codeexamplecolumns}
+The key \macro{store in} can also be set using \macro{\JSONParseSet}. Calling \macro{store in={}} will reset it to its default (empty) value.
+
\begin{macrodef}*
|\JSONParseExpandableValue|{<token variable>}{<key>}
\end{macrodef}
@@ -554,7 +558,7 @@
\begin{macrodef}
|\JSONParseArrayMapInline|[<options>]{<token variable>}{<key>}{<inline function>}
\end{macrodef}
-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 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.
Using the above example, the mechanism could be implemented as follows:
@@ -594,7 +598,7 @@
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'').
-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. It is important to note that the inline function needs to be fully expandable. For example, it is not possible to use \macro{\JSONParseValue} in the code of the inline function while \macro{\JSONParseExpandableValue} is allowed.
+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. It is important to note that the inline function needs to be fully expandable. For example, it is not possible to use \macro{\JSONParseValue} in the code of the inline function while \macro{\JSONParseExpandableValue} is allowed. Note that the key \macro{store in} cannot be combined with nested use of \macro{\JSONParseArrayMapInline} because \macro{\JSONParseArrayMapInline} itself is not expandable.
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}.
@@ -710,7 +714,7 @@
\begin{itemize}
\item Information about the keys \macro{escape} and \macro{rescan} can be found above in section \ref{sec:escaping}.
-\item Information about the key \macro{store in} can be found \hyperlink{macro:parsevalue}{above} in the description to the command \macro{\JSONParseValue} as well as the description to the commands \macro{\JSONParseKeys}, \macro{\JSONParseArrayCount}, \macro{\JSONParseArrayUse} and \macro{\JSONParseArrayMapInline} repsectively.
+\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}.
\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}.
\end{itemize}
@@ -738,7 +742,7 @@
|global|
|global|={<boolean>}
\end{macrodef}
-The key \macro{global} can be used together with the key \macro{store in} to globally set the value of the relevant token list. Information about the key \macro{store in} can be found in the description to the command \macro{\JSONParseValue} \hyperlink{macro:parsevalue}{above} for example.
+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 \hyperlink{key:storein}{above}.
\section{Deprecated commands}
@@ -874,7 +878,7 @@
\begin{macrodef}
|\jsonparse_filter:Nn| <token variable> {<key>}
\end{macrodef}
-The command \macro{\jsonparse_filter: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. If the second argument matches the pseudo key \macro{.} (or the string defined using the key \macro{child sep}) excactly, the complete property list except for this key is returned.
+The command \macro{\jsonparse_filter: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. If the second argument matches the pseudo key \macro{.} (or the string defined using the key \macro{child sep}) exactly, the complete property list except for this key is returned.
\begin{macrodef}
|\jsonparse_array_count:NN| <token variable> <integer variable>
@@ -883,7 +887,9 @@
\begin{macrodef}*
|\jsonparse_if_num:n|?TF? {<string>} {<true code>} {<false code>}
+|\jsonparse_if_num:V|?TF? {<string>} {<true code>} {<false code>}
|\jsonparse_if_num_p:n| {<string>}
+|\jsonparse_if_num_p:V| {<string>}
\end{macrodef}
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}).
Modified: trunk/Master/texmf-dist/tex/latex/jsonparse/jsonparse.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/jsonparse/jsonparse.sty 2025-03-24 19:46:48 UTC (rev 74733)
+++ trunk/Master/texmf-dist/tex/latex/jsonparse/jsonparse.sty 2025-03-24 19:46:57 UTC (rev 74734)
@@ -10,7 +10,7 @@
%
% This work has the LPPL maintenance status `maintained'.
%
-\ProvidesExplPackage {jsonparse} {2025-02-24} {1.2.1}
+\ProvidesExplPackage {jsonparse} {2025-03-23} {1.2.3}
{A handy way to parse, store and access JSON data from files or strings in LaTeX documents}
\msg_new:nnn { jsonparse } { old-kernel } {
@@ -296,7 +296,7 @@
% ===
-\exp_args_generate:n { NoeV , Noee , NoeeV }
+\exp_args_generate:n { NoeV , Noee , NoeeVV }
\cs_generate_variant:Nn \file_input:n { e }
\cs_generate_variant:Nn \tl_gset:Nn { Ne , ce }
@@ -313,7 +313,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_function:nnN { nVN }
+\cs_generate_variant:Nn \int_step_function:nnN { nnc , 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 }
@@ -349,6 +349,8 @@
\prop_new_linked:N \l__jsonparse_temp_copy_prop
}
+\scan_new:N \s__jsonparse_mark
+
\tl_new:N \g__jsonparse_json_tl
\tl_new:N \l__jsonparse_input_tl
\tl_new:N \l__jsonparse_temp_tl
@@ -378,6 +380,7 @@
\clist_new:N \l__jsonparse_array_map_keys_clist
\str_new:N \l__jsonparse_array_map_function_str
+\int_new:N \g__jsonparse_array_map_inline_int
\bool_new:N \l__jsonparse_prop_map_first_bool
\bool_new:N \l__jsonparse_externalize_load_bool
@@ -419,6 +422,7 @@
\exp_last_unbraced:Ne
\__jsonparse_parse_num:w { \tl_to_str:e { \tl_trim_spaces:n {#1} } } \q_stop
}
+\prg_generate_conditional_variant:Nnn \jsonparse_if_num:n { V } { p , T , F , TF }
\cs_new:Npn \__jsonparse_parse_num:w #1#2 \q_stop {
\cs_if_exist_use:cTF { __jsonparse_parse_num_first_ #1 :w } {
@@ -608,7 +612,7 @@
\__jsonparse_parse_other:w \l__jsonparse_input_tl \q_stop
}
}
-\cs_generate_variant:Nn \jsonparse_parse:n { e , o }
+\cs_generate_variant:Nn \jsonparse_parse:n { o , e }
\cs_new_protected:Npn \jsonparse_parse_to_prop:Nn #1#2 {
\bool_if:NT \l__jsonparse_debug_mode_bool {
@@ -810,20 +814,22 @@
\cs_new_protected:Npn \__jsonparse_parse_other:w #1 \q_stop {
\__jsonparse_array_key_set:
- \tl_set:Nn \l__jsonparse_remainder_tl {#1}
- \tl_set:Nn \l__jsonparse_temp_tl { #1 , }
- \tl_replace_once:Nnn \l__jsonparse_temp_tl { ] } { , }
- \tl_replace_once:Non \l__jsonparse_temp_tl { \c_right_brace_str } { , }
+ \tl_set:Nn \l__jsonparse_temp_tl { #1 \s__jsonparse_mark }
+ \tl_replace_once:Nnn \l__jsonparse_temp_tl { , } { \s__jsonparse_mark , }
+ \tl_replace_once:Nnn \l__jsonparse_temp_tl { ] } { \s__jsonparse_mark ] }
+ \tl_replace_once:Non \l__jsonparse_temp_tl { \c_right_brace_str } { \s__jsonparse_mark \c_right_brace_str }
\exp_last_unbraced:No
\__jsonparse_parse_other_aux:w \l__jsonparse_temp_tl \q_stop
}
-\cs_new_protected:Npn \__jsonparse_parse_other_aux:w #1 , #2 \q_stop {
+\cs_new_protected:Npn \__jsonparse_parse_other_aux:w #1 \s__jsonparse_mark #2 \q_stop {
+ \tl_set:Nn \l__jsonparse_remainder_tl {#2}
+ \tl_remove_all:Nn \l__jsonparse_remainder_tl { \s__jsonparse_mark }
\tl_set:Ne \l__jsonparse_temp_tl { \tl_trim_spaces:n {#1} }
\cs_if_exist_use:cF { __jsonparse_parse_ \str_casefold:o { \l__jsonparse_temp_tl } : } {
\bool_if:NTF \l__jsonparse_check_num_bool {
- \jsonparse_if_num:nTF {#1} {
- \tl_set:Nn \l__jsonparse_val_tl {#1}
+ \jsonparse_if_num:VTF \l__jsonparse_temp_tl {
+ \tl_set:No \l__jsonparse_val_tl { \l__jsonparse_temp_tl }
\prop_gput:Nee \g_jsonparse_entries_prop
{ \l__jsonparse_key_tl } { \l__jsonparse_val_tl }
% number
@@ -839,7 +845,7 @@
{ \l__jsonparse_key_tl } {#1}
}
} {
- \tl_set:Nn \l__jsonparse_val_tl {#1}
+ \tl_set:No \l__jsonparse_val_tl { \l__jsonparse_temp_tl }
\prop_gput:Nee \g_jsonparse_entries_prop
{ \l__jsonparse_key_tl } { \l__jsonparse_val_tl }
% number
@@ -851,14 +857,6 @@
}
}
}
- \tl_set:Ne \l__jsonparse_remainder_tl { \tl_trim_spaces:e { \l__jsonparse_remainder_tl } }
- \tl_set:Ne \l__jsonparse_remainder_tl {
- \tl_range:Nen \l__jsonparse_remainder_tl {
- \int_eval:n {
- \tl_count:n {#1} + 1
- }
- } { -1 }
- }
\__jsonparse_parse_remainder:
}
@@ -1621,39 +1619,54 @@
}
% ===
-\cs_new:Npn \__jsonparse_warning_function_expandable: {
- \str_if_in:eeT { \tl_to_str:o { \__jsonparse_array_map_inline_code:n { } } }
- { \c_backslash_str JSONParseValue }
- { \msg_error:nn { jsonparse } { nested-non-expandable } }
+\cs_new:Npn \__jsonparse_warning_function_expandable:n #1 {
+ \clist_map_inline:nn {
+ JSONParseValue ,
+ JSONParseKeys ,
+ JSONParseArrayCount ,
+ JSONParseArrayUse ,
+ JSONParseArrayMapFunction ,
+ JSONParseArrayMapInline
+ } {
+ \str_if_in:eeT { \exp_args:No \tl_to_str:o {
+ \cs:w __jsonparse_array_map_inline_ \int_to_roman:n {#1} _code:n \cs_end: { }
+ } } { \c_backslash_str ##1 ~ } {
+ \msg_error:nn { jsonparse } { nested-non-expandable }
+ }
+ }
}
+\cs_generate_variant:Nn \__jsonparse_warning_function_expandable:n { V }
-\cs_new:Npn \__jsonparse_array_map_inline_code:n #1 { }
-
-\cs_new:Npn \__jsonparse_array_map_inline_aux:nnnn #1#2#3#4 {
+\cs_new_protected:Npn \__jsonparse_array_map_inline_aux:nnnnn #1#2#3#4#5 {
\tl_if_empty:nTF {#1} {
- \__jsonparse_array_map_inline_auxi:nn {#3} {#4}
+ \__jsonparse_array_map_inline_auxi:nnn {#3} {#4} {#5}
} {
\bool_if:nTF {#2} {
\tl_gset:Ne #1 {
- \__jsonparse_array_map_inline_auxi:nn {#3} {#4}
+ \__jsonparse_array_map_inline_auxi:nnn {#3} {#4} {#5}
}
} {
\tl_set:Ne #1 {
- \__jsonparse_array_map_inline_auxi:nn {#3} {#4}
+ \__jsonparse_array_map_inline_auxi:nnn {#3} {#4} {#5}
}
}
}
}
-\cs_new:Npn \__jsonparse_array_map_inline_auxi:nn #1#2 {
- \int_step_function:nnN {
+\cs_new:Npn \__jsonparse_array_map_inline_auxi:nnn #1#2#3 {
+ \int_step_function:nnc {
\bool_if:nTF {#1} { 0 } { 1 }
- } {#2} \__jsonparse_array_map_inline_code:n
+ } {#2} {
+ __jsonparse_array_map_inline_ \int_to_roman:n {#3} _code:n
+ }
}
\NewDocumentCommand { \JSONParseArrayMapInline } { O{} m m +m } {
\__jsonparse_warning_undefined_prop:N #2
- \cs_gset:Npn \__jsonparse_array_map_inline_code:n ##1 {#4}
+ \int_gincr:N \g__jsonparse_array_map_inline_int
+ \cs_new:cpn {
+ __jsonparse_array_map_inline_ \int_to_roman:n { \g__jsonparse_array_map_inline_int } _code:n
+ } ##1 {#4}
\group_begin:
\keys_set_known:nnN { jsonparse / store ~ in } {#1} \l__jsonparse_unused_keys_clist
\__jsonparse_warning_unused_keys:
@@ -1664,16 +1677,19 @@
\int_decr:N \l__jsonparse_array_count_int
}
\tl_if_empty:NF \l__jsonparse_store_in_tl {
- \__jsonparse_warning_function_expandable:
+ \__jsonparse_warning_function_expandable:V \g__jsonparse_array_map_inline_int
\exp_last_unbraced:No \tl_if_exist:NF \l__jsonparse_store_in_tl {
\exp_last_unbraced:No \tl_new:N \l__jsonparse_store_in_tl
}
}
- \exp_args:NNoeeV
+ \exp_args:NNoeeVV
\group_end:
- \__jsonparse_array_map_inline_aux:nnnn { \l__jsonparse_store_in_tl }
- { \bool_if_p:N \l__jsonparse_store_in_global_bool } { \bool_if_p:N \l__jsonparse_zero_based_bool }
+ \__jsonparse_array_map_inline_aux:nnnnn
+ { \l__jsonparse_store_in_tl }
+ { \bool_if_p:N \l__jsonparse_store_in_global_bool }
+ { \bool_if_p:N \l__jsonparse_zero_based_bool }
\l__jsonparse_array_count_int
+ \g__jsonparse_array_map_inline_int
}
% ===
More information about the tex-live-commits
mailing list.