texlive[72698] Master/texmf-dist: jsonparse (29oct24)
commits+karl at tug.org
commits+karl at tug.org
Tue Oct 29 21:07:04 CET 2024
Revision: 72698
https://tug.org/svn/texlive?view=revision&revision=72698
Author: karl
Date: 2024-10-29 21:07:04 +0100 (Tue, 29 Oct 2024)
Log Message:
-----------
jsonparse (29oct24)
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 2024-10-29 20:06:54 UTC (rev 72697)
+++ trunk/Master/texmf-dist/doc/latex/jsonparse/README.md 2024-10-29 20:07:04 UTC (rev 72698)
@@ -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 2024-10-29 20:06:54 UTC (rev 72697)
+++ trunk/Master/texmf-dist/doc/latex/jsonparse/jsonparse-doc.tex 2024-10-29 20:07:04 UTC (rev 72698)
@@ -11,8 +11,8 @@
% This work has the LPPL maintenance status `maintained'.
%
\documentclass[a4paper]{article}
-\def\jsonparsefileversion{0.9.3}
-\def\jsonparsefiledate{24 October 2024}
+\def\jsonparsefileversion{0.9.5}
+\def\jsonparsefiledate{27 October 2024}
\usepackage[T1]{fontenc}
\usepackage{Alegreya}
@@ -203,6 +203,7 @@
\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.}
\begin{document}
\vspace*{-1cm}
@@ -233,10 +234,12 @@
This key can be set either as package option or using \macro{\JSONParseSet}. It can also be set locally as option to the commands \macro{\JSONParse} and \macro{\JSONParseFromFile}.
+\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'').
+
\section{Escaping and special treatment of the input}\label{sec:escaping}
-In general, the package reads the JSON source as string, which means that all characters have category code 12 (other), except for spaces which have category code 10 (space). The \macro{\endlinechar} value is set to $-1$. Furthermore, if PDFLaTeX is used, the upper-half of the 8-bit range is set to ``active''. JSON, however, 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).
-
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}.
@@ -260,7 +263,7 @@
\JSONParseValue{\myJSONdataB}{d.b}
\end{codeexamplecolumns}
-Note that the control sequence \macro{\x} is replaced by the value exactly. Therefore, if the value happens to be a string, the control sequence \macro{\x} should be placed between quotation marks (\macro{"}) in order for the resulting string to be valid JSON.
+Note that the control sequence \macro{\x} is replaced by the value exactly. Therefore, if the value happens to be a string, the control sequence \macro{\x} should be placed between quotation marks (\macro{"}) in order for the resulting string to be valid JSON. The control sequence \macro{\x} is only available inside the \macro{\JSONParse} command, but not inside the \macro{\JSONParseFromFile} command.
\begin{macrodef}
|escape|={all}
@@ -310,7 +313,6 @@
\begin{macrodef}
|\JSONParseValue|[<options>]{<token variable>}{<key>}
-|\JSONParseExpandableValue|{<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 first argument takes the token variable that holds the parsed JSON data. The second argument takes the key to select the relevant entry from the parsed JSON data using JavaScript syntax.
@@ -322,9 +324,16 @@
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.
-Whole objects or arrays can also be output as JSON string for further use in other macros using the expandable command \macro{\JSONParseExpandableValue}.
+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}
+|\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.
+
+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}
|\JSONParseArrayValues|[<options>]{<token variable>}{<key>}[<subkey>]{<string>}
\end{macrodef}
The command \macro{\JSONParseArrayValues} is used to select all values from an array from a parsed JSON string or JSON file. The first argument takes the token variable that holds the parsed JSON data. The second argument takes the key to select the relevant entry from the parsed JSON data using JavaScript syntax. The third argument is optional and can be used to pass a subkey, i.\,e. a key that is used to select a value for every item. The last argument takes a string that is inserted between all values when they are typeset.
Modified: trunk/Master/texmf-dist/tex/latex/jsonparse/jsonparse.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/jsonparse/jsonparse.sty 2024-10-29 20:06:54 UTC (rev 72697)
+++ trunk/Master/texmf-dist/tex/latex/jsonparse/jsonparse.sty 2024-10-29 20:07:04 UTC (rev 72698)
@@ -10,8 +10,8 @@
%
% This work has the LPPL maintenance status `maintained'.
%
-\ProvidesExplPackage {jsonparse} {2024-10-24} {0.9.3}
- {JSON Parse}
+\ProvidesExplPackage {jsonparse} {2024-10-27} {0.9.5}
+ {A handy way to parse, store and access JSON data from files or strings in LaTeX documents}
\bool_new:N \l__jsonparse_debug_mode_bool
\keys_define:nn { jsonparse / global } {
@@ -305,47 +305,49 @@
\bool_new:N \l__jsonparse_num_exponent_seen_bool
\clist_const:Nn \c__jsonparse_num_digits_clist {
- 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9
+ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9
}
+\clist_const:Ne \c__jsonparse_num_others_clist {
+ \tl_to_str:n { + } ,
+ \tl_to_str:n { - } ,
+ \tl_to_str:n { . } ,
+ \tl_to_str:n { e } ,
+ \tl_to_str:n { E }
+}
+
\prg_new_conditional:Npnn \jsonparse_if_num:n #1 { p , T , F , TF } {
- \bool_set_true:N \l__jsonparse_num_bool
- \bool_set_false:N \l__jsonparse_num_zero_seen_bool
- \bool_set_false:N \l__jsonparse_num_plus_minus_seen_bool
- \bool_set_false:N \l__jsonparse_num_fraction_seen_bool
- \bool_set_false:N \l__jsonparse_num_exponent_seen_bool
- \tl_set:Nn \l__jsonparse_num_remainder_tl { #1 }
- \tl_if_empty:NTF \l__jsonparse_num_remainder_tl {
- \bool_set_false:N \l__jsonparse_num_bool
- } {
- \__jsonparse_parse_num:n {#1}
- }
- \bool_lazy_any:nT {
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { + } }
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { - } }
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { . } }
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { e } }
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { E } }
- } {
- \bool_set_false:N \l__jsonparse_num_bool
- }
- \bool_if:NTF \l__jsonparse_num_bool {
- \prg_return_true:
- } {
- \prg_return_false:
- }
+ \bool_set_true:N \l__jsonparse_num_bool
+ \bool_set_false:N \l__jsonparse_num_zero_seen_bool
+ \bool_set_false:N \l__jsonparse_num_plus_minus_seen_bool
+ \bool_set_false:N \l__jsonparse_num_fraction_seen_bool
+ \bool_set_false:N \l__jsonparse_num_exponent_seen_bool
+ \tl_set:Nn \l__jsonparse_num_remainder_tl { #1 }
+ \tl_if_empty:NTF \l__jsonparse_num_remainder_tl {
+ \bool_set_false:N \l__jsonparse_num_bool
+ } {
+ \__jsonparse_parse_num:n {#1}
+ }
+ \clist_if_in:NVT \c__jsonparse_num_others_clist \l__jsonparse_num_input_last_tl {
+ \bool_set_false:N \l__jsonparse_num_bool
+ }
+ \bool_if:NTF \l__jsonparse_num_bool {
+ \prg_return_true:
+ } {
+ \prg_return_false:
+ }
}
\cs_new:Npn \__jsonparse_parse_num:n #1 {
- \tl_set:Ne \l__jsonparse_num_input_tl { \tl_trim_spaces:e {#1} }
- \tl_if_empty:NF \l__jsonparse_num_input_tl {
- \cs_if_exist_use:cTF { __jsonparse_parse_num_ \str_head_ignore_spaces:o { \l__jsonparse_num_input_tl } :w } {
- \l__jsonparse_num_input_tl \q_stop
- } {
- \exp_last_unbraced:No
- \__jsonparse_parse_num_other:w \l__jsonparse_num_input_tl \q_stop
- }
+ \tl_set:Ne \l__jsonparse_num_input_tl { \tl_trim_spaces:e {#1} }
+ \tl_if_empty:NF \l__jsonparse_num_input_tl {
+ \cs_if_exist_use:cTF { __jsonparse_parse_num_ \str_head_ignore_spaces:o { \l__jsonparse_num_input_tl } :w } {
+ \l__jsonparse_num_input_tl \q_stop
+ } {
+ \exp_last_unbraced:No
+ \__jsonparse_parse_num_other:w \l__jsonparse_num_input_tl \q_stop
}
+ }
}
\cs_new:cpn { __jsonparse_parse_num_ + :w } #1 \q_stop {
@@ -374,125 +376,107 @@
}
\clist_map_inline:Nn \c__jsonparse_num_digits_clist {
- \cs_new:cpn { __jsonparse_parse_num_ #1 :w } ##1 \q_stop {
- \exp_last_unbraced:No
- \__jsonparse_parse_num_digit:w ##1 \q_stop
- }
+ \cs_new:cpn { __jsonparse_parse_num_ #1 :w } ##1 \q_stop {
+ \exp_last_unbraced:No
+ \__jsonparse_parse_num_digit:w ##1 \q_stop
+ }
}
\cs_new:Npn \__jsonparse_parse_num_plus_minus:w #1 \q_stop {
- \bool_if:NTF \l__jsonparse_num_plus_minus_seen_bool {
+ \bool_if:NTF \l__jsonparse_num_plus_minus_seen_bool {
+ \tl_set:Nn \l__jsonparse_num_remainder_tl { }
+ \bool_set_false:N \l__jsonparse_num_bool
+ } {
+ \tl_if_empty:NTF \l__jsonparse_num_input_last_tl {
+ \str_if_eq:enT { \tl_head:n {#1} } { + } {
\tl_set:Nn \l__jsonparse_num_remainder_tl { }
\bool_set_false:N \l__jsonparse_num_bool
+ }
} {
- \tl_if_empty:NTF \l__jsonparse_num_input_last_tl {
- \str_if_eq:enT { \tl_head:n {#1} } { + } {
- \tl_set:Nn \l__jsonparse_num_remainder_tl { }
- \bool_set_false:N \l__jsonparse_num_bool
- }
- } {
- \bool_lazy_any:nT {
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { + } }
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { - } }
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { . } }
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { e } }
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { E } }
- } {
- \tl_set:Nn \l__jsonparse_num_remainder_tl { }
- \bool_set_false:N \l__jsonparse_num_bool
- }
- }
+ \clist_if_in:NVT \c__jsonparse_num_others_clist \l__jsonparse_num_input_last_tl {
+ \tl_set:Nn \l__jsonparse_num_remainder_tl { }
+ \bool_set_false:N \l__jsonparse_num_bool
+ }
}
- \bool_set_true:N \l__jsonparse_num_plus_minus_seen_bool
- \tl_set:Ne \l__jsonparse_num_input_last_tl { \tl_head:n {#1} }
- \tl_set:Ne \l__jsonparse_num_remainder_tl { \tl_tail:n {#1} }
- \__jsonparse_parse_num:n { \l__jsonparse_num_remainder_tl }
+ }
+ \bool_set_true:N \l__jsonparse_num_plus_minus_seen_bool
+ \tl_set:Ne \l__jsonparse_num_input_last_tl { \tl_head:n {#1} }
+ \tl_set:Ne \l__jsonparse_num_remainder_tl { \tl_tail:n {#1} }
+ \__jsonparse_parse_num:n { \l__jsonparse_num_remainder_tl }
}
\cs_new:Npn \__jsonparse_parse_num_fraction:w #1 \q_stop {
- \bool_if:NTF \l__jsonparse_num_fraction_seen_bool {
+ \bool_if:NTF \l__jsonparse_num_fraction_seen_bool {
+ \tl_set:Nn \l__jsonparse_num_remainder_tl { }
+ \bool_set_false:N \l__jsonparse_num_bool
+ } {
+ \tl_if_empty:NTF \l__jsonparse_num_input_last_tl {
+ \tl_set:Nn \l__jsonparse_num_remainder_tl { }
+ \bool_set_false:N \l__jsonparse_num_bool
+ } {
+ \clist_if_in:NVT \c__jsonparse_num_others_clist \l__jsonparse_num_input_last_tl {
\tl_set:Nn \l__jsonparse_num_remainder_tl { }
- \bool_set_false:N \l__jsonparse_num_bool
- } {
- \tl_if_empty:NTF \l__jsonparse_num_input_last_tl {
- \tl_set:Nn \l__jsonparse_num_remainder_tl { }
- \bool_set_false:N \l__jsonparse_num_bool
- } {
- \bool_lazy_any:nT {
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { + } }
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { - } }
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { . } }
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { e } }
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { E } }
- } {
- \tl_set:Nn \l__jsonparse_num_remainder_tl { }
- \bool_set_false:N \l__jsonparse_num_bool
- }
- }
+ \bool_set_false:N \l__jsonparse_num_bool
+ }
}
- \bool_set_false:N \l__jsonparse_num_zero_seen_bool
- \bool_set_true:N \l__jsonparse_num_plus_minus_seen_bool
- \bool_set_true:N \l__jsonparse_num_fraction_seen_bool
- \tl_set:Ne \l__jsonparse_num_input_last_tl { \tl_head:n {#1} }
- \tl_set:Ne \l__jsonparse_num_remainder_tl { \tl_tail:n {#1} }
- \__jsonparse_parse_num:n { \l__jsonparse_num_remainder_tl }
+ }
+ \bool_set_false:N \l__jsonparse_num_zero_seen_bool
+ \bool_set_true:N \l__jsonparse_num_plus_minus_seen_bool
+ \bool_set_true:N \l__jsonparse_num_fraction_seen_bool
+ \tl_set:Ne \l__jsonparse_num_input_last_tl { \tl_head:n {#1} }
+ \tl_set:Ne \l__jsonparse_num_remainder_tl { \tl_tail:n {#1} }
+ \__jsonparse_parse_num:n { \l__jsonparse_num_remainder_tl }
}
\cs_new:Npn \__jsonparse_parse_num_exponent:w #1 \q_stop {
- \bool_if:NTF \l__jsonparse_num_exponent_seen_bool {
+ \bool_if:NTF \l__jsonparse_num_exponent_seen_bool {
+ \tl_set:Nn \l__jsonparse_num_remainder_tl { }
+ \bool_set_false:N \l__jsonparse_num_bool
+ } {
+ \tl_if_empty:NTF \l__jsonparse_num_input_last_tl {
+ \tl_set:Nn \l__jsonparse_num_remainder_tl { }
+ \bool_set_false:N \l__jsonparse_num_bool
+ } {
+ \clist_if_in:NVT \c__jsonparse_num_others_clist \l__jsonparse_num_input_last_tl {
\tl_set:Nn \l__jsonparse_num_remainder_tl { }
- \bool_set_false:N \l__jsonparse_num_bool
- } {
- \tl_if_empty:NTF \l__jsonparse_num_input_last_tl {
- \tl_set:Nn \l__jsonparse_num_remainder_tl { }
- \bool_set_false:N \l__jsonparse_num_bool
- } {
- \bool_lazy_any:nT {
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { + } }
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { - } }
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { . } }
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { e } }
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { E } }
- } {
- \tl_set:Nn \l__jsonparse_num_remainder_tl { }
- \bool_set_false:N \l__jsonparse_num_bool
- }
- }
+ \bool_set_false:N \l__jsonparse_num_bool
+ }
}
- \bool_set_false:N \l__jsonparse_num_zero_seen_bool
- \bool_set_false:N \l__jsonparse_num_plus_minus_seen_bool
- \bool_set_true:N \l__jsonparse_num_fraction_seen_bool
- \bool_set_true:N \l__jsonparse_num_exponent_seen_bool
- \tl_set:Ne \l__jsonparse_num_input_last_tl { \tl_head:n {#1} }
- \tl_set:Ne \l__jsonparse_num_remainder_tl { \tl_tail:n {#1} }
- \__jsonparse_parse_num:n { \l__jsonparse_num_remainder_tl }
+ }
+ \bool_set_false:N \l__jsonparse_num_zero_seen_bool
+ \bool_set_false:N \l__jsonparse_num_plus_minus_seen_bool
+ \bool_set_true:N \l__jsonparse_num_fraction_seen_bool
+ \bool_set_true:N \l__jsonparse_num_exponent_seen_bool
+ \tl_set:Ne \l__jsonparse_num_input_last_tl { \tl_head:n {#1} }
+ \tl_set:Ne \l__jsonparse_num_remainder_tl { \tl_tail:n {#1} }
+ \__jsonparse_parse_num:n { \l__jsonparse_num_remainder_tl }
}
\cs_new:Npn \__jsonparse_parse_num_digit:w #1 \q_stop {
- \bool_lazy_any:nTF {
- { \tl_if_empty_p:N \l__jsonparse_num_input_last_tl }
- { \bool_lazy_and_p:nn
- { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { - } }
- { \bool_not_p:n { \l__jsonparse_num_exponent_seen_bool } }
- }
- } {
- \str_if_eq:enT { \tl_head:n {#1} } { 0 } {
- \bool_set_true:N \l__jsonparse_num_zero_seen_bool
- }
- } {
- \bool_if:NT \l__jsonparse_num_zero_seen_bool {
- \tl_set:Nn \l__jsonparse_num_remainder_tl { }
- \bool_set_false:N \l__jsonparse_num_bool
- }
+ \bool_lazy_any:nTF {
+ { \tl_if_empty_p:N \l__jsonparse_num_input_last_tl }
+ { \bool_lazy_and_p:nn
+ { \str_if_eq_p:Vn \l__jsonparse_num_input_last_tl { - } }
+ { \bool_not_p:n { \l__jsonparse_num_exponent_seen_bool } }
}
- \tl_set:Ne \l__jsonparse_num_input_last_tl { \tl_head:n {#1} }
- \tl_set:Ne \l__jsonparse_num_remainder_tl { \tl_tail:n {#1} }
- \__jsonparse_parse_num:n { \l__jsonparse_num_remainder_tl }
+ } {
+ \str_if_eq:enT { \tl_head:n {#1} } { 0 } {
+ \bool_set_true:N \l__jsonparse_num_zero_seen_bool
+ }
+ } {
+ \bool_if:NT \l__jsonparse_num_zero_seen_bool {
+ \tl_set:Nn \l__jsonparse_num_remainder_tl { }
+ \bool_set_false:N \l__jsonparse_num_bool
+ }
+ }
+ \tl_set:Ne \l__jsonparse_num_input_last_tl { \tl_head:n {#1} }
+ \tl_set:Ne \l__jsonparse_num_remainder_tl { \tl_tail:n {#1} }
+ \__jsonparse_parse_num:n { \l__jsonparse_num_remainder_tl }
}
\cs_new:Npn \__jsonparse_parse_num_other:w #1 \q_stop {
- \tl_set:Nn \l__jsonparse_num_remainder_tl { }
- \bool_set_false:N \l__jsonparse_num_bool
+ \tl_set:Nn \l__jsonparse_num_remainder_tl { }
+ \bool_set_false:N \l__jsonparse_num_bool
}
% ===
@@ -833,7 +817,7 @@
% ===
-\cs_new:Npn \__json_nested_construct_cs:Nnn #1 #2 #3 {
+\cs_new:Npn \__json_nested_construct_cs:Nnn #1#2#3 {
\cs_set:Npn #1 #2 ##1 #3 #2 ##2 #3 {
\prop_item:ce {##1} {##2}
}
@@ -914,7 +898,6 @@
\cs_set:Npn \r { \exp_not:N \r }
\cs_set:Npn \t { \exp_not:N \t }
\cs_set:Npn \u { \exp_not:N \u }
- \cs_set:Npn \x [ ##1 ] [ ##2 ] { \prop_item:ce {##1} {##2} }
\file_get:nnN {#3} { \cctab_select:N \c__jsonparse_json_escape_cctab } \g__jsonparse_json_tl
\exp_args:NNe \jsonparse_parse_to_prop:Nn #2 { \g__jsonparse_json_tl }
\group_end:
@@ -929,9 +912,13 @@
\prop_item:Ne #1 {#2}
}
-\cs_set_eq:NN \__jsonparse_tex_quote \"
-\cs_set_eq:NN \__jsonparse_tex_backslash \\
+\cs_set_eq:NN \__jsonparse_tex_quote: \"
+\cs_set_eq:NN \__jsonparse_tex_backslash: \\
+\cs_new:Npn \__jsonparse_unicode_char:NNNN #1#2#3#4 {
+ \symbol{ " \str_uppercase:n { #1 #2 #3 #4 } } { }
+}
+
\cs_new:Npn \__jsonparse_rescan:n #1 {
\group_begin:
\cs_set:Npn \" { " }
@@ -942,10 +929,10 @@
\cs_set:Npn \n { \l__jsonparse_linefeed_str }
\cs_set:Npn \r { \l__jsonparse_carriage_return_str }
\cs_set:Npn \t { \l__jsonparse_horizontal_tab_str }
- \cs_set:Npn \u { \char" }
+ \cs_set_eq:NN \u \__jsonparse_unicode_char:NNNN
\tl_set:Ne \l__jsonparse_temp_tl {#1}
- \cs_set_eq:NN \" \__jsonparse_tex_quote
- \cs_set_eq:NN \\ \__jsonparse_tex_backslash
+ \cs_set_eq:NN \" \__jsonparse_tex_quote:
+ \cs_set_eq:NN \\ \__jsonparse_tex_backslash:
\bool_if:NT \l__jsonparse_escape_number_sign_bool {
\tl_replace_all:Noe \l__jsonparse_temp_tl { \c_hash_str } { \c_backslash_str \c_hash_str }
}
More information about the tex-live-commits
mailing list.