texlive[74289] branches/branch2024.final/Master/texmf-dist: jsonparse
commits+karl at tug.org
commits+karl at tug.org
Tue Feb 25 21:43:57 CET 2025
Revision: 74289
https://tug.org/svn/texlive?view=revision&revision=74289
Author: karl
Date: 2025-02-25 21:43:57 +0100 (Tue, 25 Feb 2025)
Log Message:
-----------
jsonparse (branch) (25feb25)
Modified Paths:
--------------
branches/branch2024.final/Master/texmf-dist/doc/latex/jsonparse/README.md
branches/branch2024.final/Master/texmf-dist/doc/latex/jsonparse/jsonparse-doc.pdf
branches/branch2024.final/Master/texmf-dist/doc/latex/jsonparse/jsonparse-doc.tex
branches/branch2024.final/Master/texmf-dist/tex/latex/jsonparse/jsonparse.sty
Modified: branches/branch2024.final/Master/texmf-dist/doc/latex/jsonparse/README.md
===================================================================
--- branches/branch2024.final/Master/texmf-dist/doc/latex/jsonparse/README.md 2025-02-25 20:43:44 UTC (rev 74288)
+++ branches/branch2024.final/Master/texmf-dist/doc/latex/jsonparse/README.md 2025-02-25 20:43:57 UTC (rev 74289)
@@ -1,4 +1,4 @@
-
+

Modified: branches/branch2024.final/Master/texmf-dist/doc/latex/jsonparse/jsonparse-doc.pdf
===================================================================
(Binary files differ)
Modified: branches/branch2024.final/Master/texmf-dist/doc/latex/jsonparse/jsonparse-doc.tex
===================================================================
--- branches/branch2024.final/Master/texmf-dist/doc/latex/jsonparse/jsonparse-doc.tex 2025-02-25 20:43:44 UTC (rev 74288)
+++ branches/branch2024.final/Master/texmf-dist/doc/latex/jsonparse/jsonparse-doc.tex 2025-02-25 20:43:57 UTC (rev 74289)
@@ -11,8 +11,8 @@
% This work has the LPPL maintenance status `maintained'.
%
\documentclass[a4paper]{article}
-\def\jsonparsefileversion{1.2.0}
-\def\jsonparsefiledate{22 February 2025}
+\def\jsonparsefileversion{1.2.1}
+\def\jsonparsefiledate{24 February 2025}
\usepackage[T1]{fontenc}
\usepackage{Alegreya}
@@ -263,6 +263,7 @@
\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.2.1}{2025/02/24}{Unified functions, added option to store result globally.}
\begin{document}
\vspace*{-1cm}
@@ -364,7 +365,7 @@
\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 globally 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).
@@ -393,13 +394,11 @@
\begin{macrodef}
|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 globally in another token variable.
+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.
-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 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.
-
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 globally 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 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.
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:
@@ -711,7 +710,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 above in the description to the command \macro{\JSONParseValue} \hyperlink{macro:parsevalue}{above} 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{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 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}
@@ -735,6 +734,12 @@
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}.
+\begin{macrodef}
+|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.
+
\section{Deprecated commands}
The following commands displayed in red boxes on the left have been deprecated and the relevant replacement displayed in green boxes on the right 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.
@@ -798,12 +803,14 @@
\begin{macroreplacement}
|\JSONParseArrayMapFunction|
[<1>, code before={<6>},
- code after={<7>}]
+ code after={<7>}]
{<2>}{<3>}[<4>]{\<5>}
\end{macroreplacement}
-To ensure backward compatibility, the deprecated commands are still supported, but their use is not recommended.
+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.
+To ensure backward compatibility, the deprecated commands are still supported, but their use is not recommended. The commands \macro{\JSONParseSetRescanValue} and \macro{\JSONParseSetKeys} will locally set the relevant token variable.
+
\section{L3 commands}
The following commands are provided for defining user functions by package authors. For the conditional functions described above, apart from the variant that provides a true and a false branch, the and 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.
@@ -820,9 +827,16 @@
|\jsonparse_parse_to_prop:No| <token variable> {<JSON string>}
|\jsonparse_parse_to_prop:Ne| <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, globally 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_parse_to_prop_local:Nn| <token variable> {<JSON string>}
+|\jsonparse_parse_to_prop_local:No| <token variable> {<JSON string>}
+|\jsonparse_parse_to_prop_local:Ne| <token variable> {<JSON string>}
+\end{macrodef}
+The command \macro{\jsonparse_parse_to_prop_local:Nn} works in the very same way as the command \macro{\jsonparse_parse_to_prop:Nn}, but the property list is set locally.
+
+\begin{macrodef}
|\jsonparse_parse_keys:NN| <token variable> <string variable>
\end{macrodef}
The command \macro{\jsonparse_parse_keys:NN} processes the token variable given as the first arguments as property list and selects all top-level keys which are then stored in the string variable as JSON array. The pseudo key \macro{.} (or the string defined using the key \macro{child sep}) to select the complete JSON data is ignored. If the JSON data is an array, the indices (wrapped into the separators defined by \macro{separator/array left} and \macro{separator/array right}) of the items are used as keys.
Modified: branches/branch2024.final/Master/texmf-dist/tex/latex/jsonparse/jsonparse.sty
===================================================================
--- branches/branch2024.final/Master/texmf-dist/tex/latex/jsonparse/jsonparse.sty 2025-02-25 20:43:44 UTC (rev 74288)
+++ branches/branch2024.final/Master/texmf-dist/tex/latex/jsonparse/jsonparse.sty 2025-02-25 20:43:57 UTC (rev 74289)
@@ -10,7 +10,7 @@
%
% This work has the LPPL maintenance status `maintained'.
%
-\ProvidesExplPackage {jsonparse} {2025-02-22} {1.2.0}
+\ProvidesExplPackage {jsonparse} {2025-02-24} {1.2.1}
{A handy way to parse, store and access JSON data from files or strings in LaTeX documents}
\msg_new:nnn { jsonparse } { old-kernel } {
@@ -83,7 +83,9 @@
\msg_new:nnn { jsonparse } { unknown-key } {
\msg_warning_text:n { jsonparse } \iow_newline:
- Ignoring ~ unknown ~ key: ~ #1.
+ Ignoring ~ key: ~ #1. \iow_newline:
+ The ~ key ~ is ~ either ~ unknown ~ or ~
+ not ~ supported ~ by ~ this ~ function.
}
\msg_new:nnn { jsonparse } { saving-external } {
@@ -128,8 +130,10 @@
\tl_new:N \l__jsonparse_array_map_code_before_tl
\tl_new:N \l__jsonparse_array_map_code_after_tl
-\tl_new:N \l__jsonparse_array_map_store_in_tl
+\tl_new:N \l__jsonparse_store_in_tl
+\bool_new:N \l__jsonparse_store_in_global_bool
+
\clist_new:N \l__jsonparse_unused_keys_clist
\clist_const:Nn \c__jsonparse_escape_tex_chars_clist {
@@ -243,11 +247,14 @@
\keys_define:nn { jsonparse / map } {
code ~ before .tl_set:N = \l__jsonparse_array_map_code_before_tl ,
- code ~ after .tl_set:N = \l__jsonparse_array_map_code_after_tl ,
+ code ~ after .tl_set:N = \l__jsonparse_array_map_code_after_tl
}
\keys_define:nn { jsonparse / store ~ in } {
- store ~ in .tl_set:N = \l__jsonparse_array_map_store_in_tl
+ store ~ in .tl_set:N = \l__jsonparse_store_in_tl ,
+ global .bool_set:N = \l__jsonparse_store_in_global_bool ,
+ global .default:n = { true } ,
+ global .initial:n = { false }
}
\cs_new_protected:Npn \__jsonparse_warning_unused_keys: {
@@ -289,7 +296,7 @@
% ===
-\exp_args_generate:n { NeoV }
+\exp_args_generate:n { NoeV , Noee , NoeeV }
\cs_generate_variant:Nn \file_input:n { e }
\cs_generate_variant:Nn \tl_gset:Nn { Ne , ce }
@@ -365,8 +372,9 @@
\int_new:N \l__jsonparse_array_keys_index_int
\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_sep_tl
+\str_new:N \l__jsonparse_array_use_key_str
+\seq_new:N \g__jsonparse_array_use_temp_seq
+\tl_new:N \l__jsonparse_array_use_temp_tl
\clist_new:N \l__jsonparse_array_map_keys_clist
\str_new:N \l__jsonparse_array_map_function_str
@@ -620,6 +628,24 @@
}
\cs_generate_variant:Nn \jsonparse_parse_to_prop:Nn { No , Ne }
+\cs_new_protected:Npn \jsonparse_parse_to_prop_local:Nn #1#2 {
+ \bool_if:NT \l__jsonparse_debug_mode_bool {
+ \msg_log:nne { jsonparse } { debug-info } {
+ \iow_newline:
+ Parsing ~ JSON ~ ...
+ }
+ }
+ \prop_clear:N \g_jsonparse_entries_prop
+ \jsonparse_parse:n {#2}
+ \prop_set_eq:NN #1 \g_jsonparse_entries_prop
+ \bool_if:NT \l__jsonparse_debug_mode_bool {
+ \msg_log:nne { jsonparse } { debug-info } {
+ JSON ~ parsing ~ done. \iow_newline:
+ }
+ }
+}
+\cs_generate_variant:Nn \jsonparse_parse_to_prop_local:Nn { No , Ne }
+
% ===
\cs_new_protected:cpn { __jsonparse_parse_ \c_left_brace_str :w } #1 \q_stop {
@@ -1177,8 +1203,10 @@
\cs_new_protected:Npn \jsonparse_set_rescan:Nn #1#2 {
\group_begin:
\__jsonparse_rescan_setup:Nn \l__jsonparse_temp_tl {#2}
- \tl_set_rescan:Nno #1 { } { \l__jsonparse_temp_tl }
+ \tl_set_rescan:Nno \l__jsonparse_temp_copy_tl { } { \l__jsonparse_temp_tl }
+ \exp_args:NNNV
\group_end:
+ \tl_set:Nn #1 \l__jsonparse_temp_copy_tl
}
\cs_generate_variant:Nn \jsonparse_set_rescan:Nn { Ne }
@@ -1195,8 +1223,9 @@
\tl_set_eq:NN \l__jsonparse_temp_copy_tl #1
\__jsonparse_rescan_setup:Nn \l__jsonparse_temp_tl {#2}
\tl_set_rescan:Nno #1 { } { \l__jsonparse_temp_tl }
- \tl_put_left:NV #1 \l__jsonparse_temp_copy_tl
+ \exp_args:NNNV
\group_end:
+ \tl_put_left:Nn #1 \l__jsonparse_temp_copy_tl
}
\cs_generate_variant:Nn \jsonparse_put_right_rescan:Nn { Ne }
@@ -1210,6 +1239,30 @@
}
\cs_generate_variant:Nn \jsonparse_gput_right_rescan:Nn { Ne }
+\cs_new_protected:Npn \__jsonparse_parse_value_aux:nnnnn #1#2#3#4#5 {
+ \tl_if_empty:nTF {#1} {
+ \bool_if:nTF {#3} {
+ \jsonparse_rescan:e { \prop_item:Ne #4 {#5} }
+ } {
+ \prop_item:Ne #4 {#5}
+ }
+ } {
+ \bool_if:nTF {#3} {
+ \bool_if:nTF {#2} {
+ \jsonparse_gset_rescan:Ne #1 { \prop_item:Ne #4 {#5} }
+ } {
+ \jsonparse_set_rescan:Ne #1 { \prop_item:Ne #4 {#5} }
+ }
+ } {
+ \bool_if:nTF {#2} {
+ \tl_gset:Ne #1 { \prop_item:Ne #4 {#5} }
+ } {
+ \tl_set:Ne #1 { \prop_item:Ne #4 {#5} }
+ }
+ }
+ }
+}
+
\NewDocumentCommand { \JSONParseValue } { O{} m m } {
\__jsonparse_warning_undefined_prop:N #2
\group_begin:
@@ -1216,25 +1269,16 @@
\keys_set_known:nnN { jsonparse / typeset } {#1} \l__jsonparse_unused_keys_clist
\keys_set_known:noN { jsonparse / store ~ in } { \l__jsonparse_unused_keys_clist } \l__jsonparse_unused_keys_clist
\__jsonparse_warning_unused_keys:
- \tl_if_empty:NTF \l__jsonparse_array_map_store_in_tl {
- \bool_if:NTF \l__jsonparse_rescan_bool {
- \jsonparse_rescan:e { \prop_item:Ne #2 {#3} }
- } {
- \prop_item:Ne #2 {#3}
+ \tl_if_empty:NF \l__jsonparse_store_in_tl {
+ \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_last_unbraced:No \tl_if_exist:NF \l__jsonparse_array_map_store_in_tl {
- \exp_last_unbraced:No \tl_new:N \l__jsonparse_array_map_store_in_tl
- }
- \bool_if:NTF \l__jsonparse_rescan_bool {
- \exp_last_unbraced:No \jsonparse_gset_rescan:Ne \l__jsonparse_array_map_store_in_tl
- { \prop_item:Ne #2 {#3} }
- } {
- \exp_last_unbraced:No \tl_gset:Ne \l__jsonparse_array_map_store_in_tl
- { \prop_item:Ne #2 {#3} }
- }
}
+ \exp_args:NNoee
\group_end:
+ \__jsonparse_parse_value_aux:nnnnn { \l__jsonparse_store_in_tl }
+ { \bool_if_p:N \l__jsonparse_store_in_global_bool } { \bool_if_p:N \l__jsonparse_rescan_bool }
+ {#2} {#3}
}
% backward compatibility
@@ -1250,6 +1294,7 @@
\NewExpandableDocumentCommand { \JSONParseExpandableValue } { m m } {
\prop_item:Ne #1 {#2}
}
+
\cs_new_protected:Npn \__jsonparse_parse_keys:nn #1#2 {
\tl_if_in:nVF {#1} \l__jsonparse_child_sep_str {
\bool_if:NTF \l__jsonparse_prop_map_first_bool {
@@ -1268,6 +1313,18 @@
\tl_set_eq:NN #2 \l__jsonparse_keys_array_tl
}
+\cs_new_protected:Npn \__jsonparse_parse_keys_aux:nnn #1#2#3 {
+ \tl_if_empty:nTF {#1} {
+ #3
+ } {
+ \bool_if:nTF {#2} {
+ \jsonparse_parse_to_prop:No #1 {#3}
+ } {
+ \jsonparse_parse_to_prop_local:No #1 {#3}
+ }
+ }
+}
+
\NewDocumentCommand { \JSONParseKeys } { O{} m m } {
\__jsonparse_warning_undefined_prop:N #2
\group_begin:
@@ -1277,16 +1334,15 @@
\jsonparse_filter:Nn \l__jsonparse_temp_copy_prop {#3}
\bool_set_true:N \l__jsonparse_prop_map_first_bool
\jsonparse_parse_keys:NN \l__jsonparse_temp_prop \l__jsonparse_keys_tl
- \tl_if_empty:NTF \l__jsonparse_array_map_store_in_tl {
- \tl_use:N \l__jsonparse_keys_tl
- } {
- \exp_last_unbraced:No \tl_if_exist:NF \l__jsonparse_array_map_store_in_tl {
- \exp_last_unbraced:No \tl_new:N \l__jsonparse_array_map_store_in_tl
+ \tl_if_empty:NF \l__jsonparse_store_in_tl {
+ \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_last_unbraced:No \jsonparse_parse_to_prop:No \l__jsonparse_array_map_store_in_tl
- { \l__jsonparse_keys_tl }
}
+ \exp_args:NNoeV
\group_end:
+ \__jsonparse_parse_keys_aux:nnn { \l__jsonparse_store_in_tl }
+ { \bool_if_p:N \l__jsonparse_store_in_global_bool } \l__jsonparse_keys_tl
}
% backward compatibility
@@ -1321,6 +1377,18 @@
\int_set_eq:NN #2 \l__jsonparse_array_count_aux_int
}
+\cs_new_protected:Npn \__jsonparse_array_count_aux:nnn #1#2#3 {
+ \tl_if_empty:nTF {#1} {
+ #3
+ } {
+ \bool_if:nTF {#2} {
+ \tl_gset:Nn #1 {#3}
+ } {
+ \tl_set:Nn #1 {#3}
+ }
+ }
+}
+
\NewDocumentCommand { \JSONParseArrayCount } { O{} m m } {
\__jsonparse_warning_undefined_prop:N #2
\group_begin:
@@ -1329,16 +1397,15 @@
\prop_set_eq:NN \l__jsonparse_temp_copy_prop #2
\jsonparse_filter:Nn \l__jsonparse_temp_copy_prop {#3}
\jsonparse_array_count:NN \l__jsonparse_temp_copy_prop \l__jsonparse_array_count_int
- \tl_if_empty:NTF \l__jsonparse_array_map_store_in_tl {
- \int_use:N \l__jsonparse_array_count_int
- } {
- \exp_last_unbraced:No \tl_if_exist:NF \l__jsonparse_array_map_store_in_tl {
- \exp_last_unbraced:No \tl_new:N \l__jsonparse_array_map_store_in_tl
+ \tl_if_empty:NF \l__jsonparse_store_in_tl {
+ \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_last_unbraced:No \tl_gset:NV \l__jsonparse_array_map_store_in_tl
- \l__jsonparse_array_count_int
}
+ \exp_args:NNoeV
\group_end:
+ \__jsonparse_array_count_aux:nnn { \l__jsonparse_store_in_tl }
+ { \bool_if_p:N \l__jsonparse_store_in_global_bool } \l__jsonparse_array_count_int
}
% backward compatibility
@@ -1348,41 +1415,20 @@
% ===
\cs_new_protected:Npn \__jsonparse_array_use:n #1 {
- \bool_if:NTF \l__jsonparse_prop_map_first_bool {
- \bool_set_false:N \l__jsonparse_prop_map_first_bool
- } {
- \tl_if_empty:NTF \l__jsonparse_array_map_store_in_tl {
- \l__jsonparse_array_values_sep_tl
- } {
- \exp_last_unbraced:No \tl_gput_right:NV \l__jsonparse_array_map_store_in_tl
- \l__jsonparse_array_values_sep_tl
- }
- }
\bool_if:NTF \l__jsonparse_rescan_bool {
- \tl_if_empty:NTF \l__jsonparse_array_map_store_in_tl {
- \jsonparse_rescan:e {
- \prop_item:Ne \l__jsonparse_temp_copy_prop {
- \__jsonparse_array_use_index:n {#1}
- }
+ \jsonparse_set_rescan:Ne \l__jsonparse_array_use_temp_tl {
+ \prop_item:Ne \l__jsonparse_temp_copy_prop {
+ \__jsonparse_array_use_index:n {#1}
}
- } {
- \exp_last_unbraced:No \jsonparse_gput_right_rescan:Ne \l__jsonparse_array_map_store_in_tl {
- \prop_item:Ne \l__jsonparse_temp_copy_prop {
- \__jsonparse_array_use_index:n {#1}
- }
- }
}
+ \seq_gput_right:No \g__jsonparse_array_use_temp_seq {
+ \l__jsonparse_array_use_temp_tl
+ }
} {
- \tl_if_empty:NTF \l__jsonparse_array_map_store_in_tl {
+ \seq_gput_right:Ne \g__jsonparse_array_use_temp_seq {
\prop_item:Ne \l__jsonparse_temp_copy_prop {
\__jsonparse_array_use_index:n {#1}
}
- } {
- \exp_last_unbraced:No \tl_gput_right:Ne \l__jsonparse_array_map_store_in_tl {
- \prop_item:Ne \l__jsonparse_temp_copy_prop {
- \__jsonparse_array_use_index:n {#1}
- }
- }
}
}
}
@@ -1395,33 +1441,46 @@
#1
}
\l__jsonparse_array_sep_right_str
- \str_if_empty:NF \l__jsonparse_array_values_key_str {
+ \str_if_empty:NF \l__jsonparse_array_use_key_str {
\l__jsonparse_child_sep_str
- \l__jsonparse_array_values_key_str
+ \l__jsonparse_array_use_key_str
}
}
+\cs_new_protected:Npn \__jsonparse_array_use_aux:nnn #1#2#3 {
+ \tl_if_empty:nTF {#1} {
+ \seq_use:Nn \g__jsonparse_array_use_temp_seq {#3}
+ } {
+ \bool_if:nTF {#2} {
+ \tl_gset:Ne #1 { \seq_use:Nn \g__jsonparse_array_use_temp_seq {#3} }
+ } {
+ \tl_set:Ne #1 { \seq_use:Nn \g__jsonparse_array_use_temp_seq {#3} }
+ }
+ }
+}
+
\NewDocumentCommand { \JSONParseArrayUse } { O{} m m O{} m } {
\__jsonparse_warning_undefined_prop:N #2
+ \seq_gclear:N \g__jsonparse_array_use_temp_seq
\group_begin:
\keys_set_known:nnN { jsonparse / typeset } {#1} \l__jsonparse_unused_keys_clist
\keys_set_known:noN { jsonparse / store ~ in } { \l__jsonparse_unused_keys_clist } \l__jsonparse_unused_keys_clist
- \keys_set_known:noN { jsonparse / map } { \l__jsonparse_unused_keys_clist } \l__jsonparse_unused_keys_clist
\__jsonparse_warning_unused_keys:
\prop_set_eq:NN \l__jsonparse_temp_copy_prop #2
\jsonparse_filter:Nn \l__jsonparse_temp_copy_prop {#3}
\jsonparse_array_count:NN \l__jsonparse_temp_copy_prop \l__jsonparse_array_count_int
- \str_set:Ne \l__jsonparse_array_values_key_str {#4}
- \tl_set:Nn \l__jsonparse_array_values_sep_tl {#5}
- \bool_set_true:N \l__jsonparse_prop_map_first_bool
- \tl_if_empty:NF \l__jsonparse_array_map_store_in_tl {
- \exp_last_unbraced:No \tl_if_exist:NF \l__jsonparse_array_map_store_in_tl {
- \exp_last_unbraced:No \tl_new:N \l__jsonparse_array_map_store_in_tl
+ \str_set:Ne \l__jsonparse_array_use_key_str {#4}
+ \int_step_function:nN \l__jsonparse_array_count_int
+ \__jsonparse_array_use:n
+ \tl_if_empty:NF \l__jsonparse_store_in_tl {
+ \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
}
}
- \int_step_function:nN { \l__jsonparse_array_count_int }
- \__jsonparse_array_use:n
+ \exp_args:NNoe
\group_end:
+ \__jsonparse_array_use_aux:nnn { \l__jsonparse_store_in_tl }
+ { \bool_if_p:N \l__jsonparse_store_in_global_bool } {#5}
}
% backward compatibility
@@ -1570,18 +1629,27 @@
\cs_new:Npn \__jsonparse_array_map_inline_code:n #1 { }
-\cs_new:Npn \__jsonparse_array_map_inline:nnn #1#2#3 {
- \bool_if:nT {#1} {
- \__jsonparse_array_map_inline_aux:nn {#2} {#3}
+\cs_new:Npn \__jsonparse_array_map_inline_aux:nnnn #1#2#3#4 {
+ \tl_if_empty:nTF {#1} {
+ \__jsonparse_array_map_inline_auxi:nn {#3} {#4}
+ } {
+ \bool_if:nTF {#2} {
+ \tl_gset:Ne #1 {
+ \__jsonparse_array_map_inline_auxi:nn {#3} {#4}
+ }
+ } {
+ \tl_set:Ne #1 {
+ \__jsonparse_array_map_inline_auxi:nn {#3} {#4}
+ }
+ }
}
}
-\cs_new:Npn \__jsonparse_array_map_inline_aux:nn #1#2 {
+\cs_new:Npn \__jsonparse_array_map_inline_auxi:nn #1#2 {
\int_step_function:nnN {
\bool_if:nTF {#1} { 0 } { 1 }
} {#2} \__jsonparse_array_map_inline_code:n
}
-\cs_generate_variant:Nn \__jsonparse_array_map_inline_aux:nn { oV }
\NewDocumentCommand { \JSONParseArrayMapInline } { O{} m m +m } {
\__jsonparse_warning_undefined_prop:N #2
@@ -1588,7 +1656,6 @@
\cs_gset:Npn \__jsonparse_array_map_inline_code:n ##1 {#4}
\group_begin:
\keys_set_known:nnN { jsonparse / store ~ in } {#1} \l__jsonparse_unused_keys_clist
- \keys_set_known:noN { jsonparse / map } { \l__jsonparse_unused_keys_clist } \l__jsonparse_unused_keys_clist
\__jsonparse_warning_unused_keys:
\prop_set_eq:NN \l__jsonparse_temp_copy_prop #2
\jsonparse_filter:Nn \l__jsonparse_temp_copy_prop {#3}
@@ -1596,20 +1663,17 @@
\bool_if:NT \l__jsonparse_zero_based_bool {
\int_decr:N \l__jsonparse_array_count_int
}
- \tl_if_empty:NF \l__jsonparse_array_map_store_in_tl {
+ \tl_if_empty:NF \l__jsonparse_store_in_tl {
\__jsonparse_warning_function_expandable:
- \exp_last_unbraced:No \tl_if_exist:NF \l__jsonparse_array_map_store_in_tl {
- \exp_last_unbraced:No \tl_new:N \l__jsonparse_array_map_store_in_tl
+ \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_last_unbraced:No \tl_gset:Ne \l__jsonparse_array_map_store_in_tl {
- \__jsonparse_array_map_inline_aux:oV { \l__jsonparse_zero_based_bool }
- \l__jsonparse_array_count_int
- }
}
- \exp_args:NNeoV
+ \exp_args:NNoeeV
\group_end:
- \__jsonparse_array_map_inline:nnn { \tl_if_empty_p:N \l__jsonparse_array_map_store_in_tl }
- { \l__jsonparse_zero_based_bool } \l__jsonparse_array_count_int
+ \__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 }
+ \l__jsonparse_array_count_int
}
% ===
More information about the tex-live-commits
mailing list.