texlive[74743] Master/texmf-dist: jsonparse (25mar25)
commits+karl at tug.org
commits+karl at tug.org
Tue Mar 25 20:46:35 CET 2025
Revision: 74743
https://tug.org/svn/texlive?view=revision&revision=74743
Author: karl
Date: 2025-03-25 20:46:35 +0100 (Tue, 25 Mar 2025)
Log Message:
-----------
jsonparse (25mar25)
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-25 19:46:16 UTC (rev 74742)
+++ trunk/Master/texmf-dist/doc/latex/jsonparse/README.md 2025-03-25 19:46:35 UTC (rev 74743)
@@ -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-25 19:46:16 UTC (rev 74742)
+++ trunk/Master/texmf-dist/doc/latex/jsonparse/jsonparse-doc.tex 2025-03-25 19:46:35 UTC (rev 74743)
@@ -11,8 +11,8 @@
% This work has the LPPL maintenance status `maintained'.
%
\documentclass[a4paper]{article}
-\def\jsonparsefileversion{1.2.3}
-\def\jsonparsefiledate{23 March 2025}
+\def\jsonparsefileversion{1.3.0}
+\def\jsonparsefiledate{25 March 2025}
\usepackage[T1]{fontenc}
\usepackage{Alegreya}
@@ -266,6 +266,7 @@
\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.}
+\changes{v1.3.0}{2025/03/25}{Enhancements in key setting mechanism.}
\begin{document}
\vspace*{-1cm}
@@ -292,10 +293,56 @@
\begin{macrodef}
|debug|
\end{macrodef}
-The package can be loaded with the option \macro{debug}. It will then output to the log file every instance of a string, a boolean (true or false) value, a null value, a number as well as the start and end of every object and the start and end of every array that is found while parsing the JSON string or JSON file.
+The package can be loaded with the option \macro{debug}. It will then output to the log file every instance of a string, a boolean (true or false) value, a null value, a number as well as the start and end of every object and the start and end of every array that is found while parsing the JSON string or JSON file. It will also show the relevant keys associated to the values including the pseudo key \macro{.} (or the string defined using the key \macro{separator/child}) that represents the complete JSON string.
-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}.
+Let us assume that the following JSON data is parsed:
+\begin{codeexample}
+ {
+ "string" : "a" ,
+ "boolean true" : true ,
+ "boolean false" : false ,
+ "null" : null ,
+ "number" : "number" : -1.1e-1 ,
+ "array" : [ "a" , "b" , "c" ]
+ }
+\end{codeexample}
+
+This will then result to the following output to the log:
+
+\begin{codeexample}
+ Parsing JSON ...
+ (obj begin)
+ (key) string:
+ (str) a
+ (key) boolean true:
+ (tru) true
+ (key) boolean false:
+ (fal) false
+ (key) null:
+ (nul) null
+ (key) number:
+ (num) -1.1e-1
+ (arr begin)
+ (key) array[0]:
+ (str) a
+ (key) array[1]:
+ (str) b
+ (key) array[2]:
+ (str) c
+ (key) array:
+ (arr) [ "a" , "b" , "c" ]
+ (arr end)
+ (key) .:
+ (obj) { "string" : "a" , "boolean true" : true , "boolean false" :
+ false , "null" : null , "number" : "number" : -1.1e-1 , "array" :
+ [ "a" , "b" , "c" ] }
+ (obj end)
+ JSON parsing done.
+\end{codeexample}
+
+The \macro{debug} key can be set either as package option or using \macro{\JSONParseSet}. It can also be set locally as option to the commands \macro{\JSONParse} and \macro{\JSONParseFromFile}.
+
\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'').
@@ -389,7 +436,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 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 data only consists 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{separator/child}) returns the whole JSON object (or the whole JSON array if the JSON data only consists of one array) as string where all characters (except for spaces and tabs) have category code 12 (``other'').
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.
@@ -843,7 +890,7 @@
\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.
+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{separator/child}) 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.
\begin{macrodef}
|\jsonparse_rescan:n| {<JSON value>}
@@ -878,7 +925,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}) exactly, 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{separator/child}) exactly, the complete property list except for this key is returned.
\begin{macrodef}
|\jsonparse_array_count:NN| <token variable> <integer variable>
Modified: trunk/Master/texmf-dist/tex/latex/jsonparse/jsonparse.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/jsonparse/jsonparse.sty 2025-03-25 19:46:16 UTC (rev 74742)
+++ trunk/Master/texmf-dist/tex/latex/jsonparse/jsonparse.sty 2025-03-25 19:46:35 UTC (rev 74743)
@@ -10,7 +10,7 @@
%
% This work has the LPPL maintenance status `maintained'.
%
-\ProvidesExplPackage {jsonparse} {2025-03-23} {1.2.3}
+\ProvidesExplPackage {jsonparse} {2025-03-25} {1.3.0}
{A handy way to parse, store and access JSON data from files or strings in LaTeX documents}
\msg_new:nnn { jsonparse } { old-kernel } {
@@ -266,11 +266,16 @@
}
\NewDocumentCommand { \JSONParseSet } { m } {
- \keys_set_known:nnN { jsonparse / global } {#1} \l__jsonparse_unused_keys_clist
- \keys_set_known:noN { jsonparse / parse } { \l__jsonparse_unused_keys_clist } \l__jsonparse_unused_keys_clist
- \keys_set_known:noN { jsonparse / typeset } { \l__jsonparse_unused_keys_clist } \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
+ \keys_set_known:nnnN { jsonparse / global } {#1}
+ { jsonparse / global } \l__jsonparse_unused_keys_clist
+ \keys_set_known:nonN { jsonparse / parse } { \l__jsonparse_unused_keys_clist }
+ { jsonparse / parse } \l__jsonparse_unused_keys_clist
+ \keys_set_known:nonN { jsonparse / typeset } { \l__jsonparse_unused_keys_clist }
+ { jsonparse / typeset } \l__jsonparse_unused_keys_clist
+ \keys_set_known:nonN { jsonparse / store ~ in } { \l__jsonparse_unused_keys_clist }
+ { jsonparse / store ~ in } \l__jsonparse_unused_keys_clist
+ \keys_set_known:nonN { jsonparse / map } { \l__jsonparse_unused_keys_clist }
+ { jsonparse / map } \l__jsonparse_unused_keys_clist
\__jsonparse_warning_unused_keys:
}
@@ -319,7 +324,7 @@
\cs_generate_variant:Nn \prop_gput:Nnn { Nee }
\cs_generate_variant:Nn \prop_item:Nn { Ne , ce }
\cs_generate_variant:Nn \prop_put:Nnn { Nen , Nee }
-\cs_generate_variant:Nn \keys_set_known:nnN { noN }
+\cs_generate_variant:Nn \keys_set_known:nnnN { nonN }
\cs_generate_variant:Nn \iow_now:Nn { Ne }
\cs_generate_variant:Nn \iow_open:Nn { Ne }
\cs_generate_variant:Nn \codepoint_generate:nn { en }
@@ -1004,8 +1009,10 @@
\NewDocumentCommand { \JSONParse } { O{} m +v } {
\group_begin:
\str_set:Ne \l_jsonparse_current_prop_str { \cs_to_str:N #2 }
- \keys_set_known:nnN { jsonparse / global } {#1} \l__jsonparse_unused_keys_clist
- \keys_set_known:noN { jsonparse / parse } { \l__jsonparse_unused_keys_clist } \l__jsonparse_unused_keys_clist
+ \keys_set_known:nnnN { jsonparse / global } {#1}
+ { jsonparse / global } \l__jsonparse_unused_keys_clist
+ \keys_set_known:nonN { jsonparse / parse } { \l__jsonparse_unused_keys_clist }
+ { jsonparse / parse } \l__jsonparse_unused_keys_clist
\__jsonparse_warning_unused_keys:
\bool_set_false:N \l__jsonparse_externalize_load_bool
\bool_if:NT \l__jsonparse_externalize_bool {
@@ -1053,8 +1060,10 @@
}
\group_begin:
\str_set:Ne \l_jsonparse_current_prop_str { \cs_to_str:N #2 }
- \keys_set_known:nnN { jsonparse / global } {#1} \l__jsonparse_unused_keys_clist
- \keys_set_known:noN { jsonparse / parse } { \l__jsonparse_unused_keys_clist } \l__jsonparse_unused_keys_clist
+ \keys_set_known:nnnN { jsonparse / global } {#1}
+ { jsonparse / global } \l__jsonparse_unused_keys_clist
+ \keys_set_known:nonN { jsonparse / parse } { \l__jsonparse_unused_keys_clist }
+ { jsonparse / parse } \l__jsonparse_unused_keys_clist
\__jsonparse_warning_unused_keys:
\bool_set_false:N \l__jsonparse_externalize_load_bool
\bool_if:NT \l__jsonparse_externalize_bool {
@@ -1264,8 +1273,10 @@
\NewDocumentCommand { \JSONParseValue } { O{} m m } {
\__jsonparse_warning_undefined_prop:N #2
\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:nnnN { jsonparse / typeset } {#1}
+ { jsonparse / typeset } \l__jsonparse_unused_keys_clist
+ \keys_set_known:nonN { jsonparse / store ~ in } { \l__jsonparse_unused_keys_clist }
+ { jsonparse / store ~ in }\l__jsonparse_unused_keys_clist
\__jsonparse_warning_unused_keys:
\tl_if_empty:NF \l__jsonparse_store_in_tl {
\exp_last_unbraced:No \tl_if_exist:NF \l__jsonparse_store_in_tl {
@@ -1326,7 +1337,8 @@
\NewDocumentCommand { \JSONParseKeys } { O{} m m } {
\__jsonparse_warning_undefined_prop:N #2
\group_begin:
- \keys_set_known:nnN { jsonparse / store ~ in } {#1} \l__jsonparse_unused_keys_clist
+ \keys_set_known:nnnN { jsonparse / store ~ in } {#1}
+ { jsonparse / store ~ in } \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}
@@ -1390,7 +1402,8 @@
\NewDocumentCommand { \JSONParseArrayCount } { O{} m m } {
\__jsonparse_warning_undefined_prop:N #2
\group_begin:
- \keys_set_known:nnN { jsonparse / store ~ in } {#1} \l__jsonparse_unused_keys_clist
+ \keys_set_known:nnnN { jsonparse / store ~ in } {#1}
+ { jsonparse / store ~ in } \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}
@@ -1461,8 +1474,10 @@
\__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:nnnN { jsonparse / typeset } {#1}
+ { jsonparse / typeset } \l__jsonparse_unused_keys_clist
+ \keys_set_known:nonN { jsonparse / store ~ in } { \l__jsonparse_unused_keys_clist }
+ { jsonparse / store ~ in } \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}
@@ -1589,8 +1604,10 @@
{#5}
}
\group_begin:
- \keys_set_known:nnN { jsonparse / typeset } {#1} \l__jsonparse_unused_keys_clist
- \keys_set_known:noN { jsonparse / map } { \l__jsonparse_unused_keys_clist } \l__jsonparse_unused_keys_clist
+ \keys_set_known:nnnN { jsonparse / typeset } {#1}
+ { jsonparse / typeset } \l__jsonparse_unused_keys_clist
+ \keys_set_known:nonN { jsonparse / map } { \l__jsonparse_unused_keys_clist }
+ { jsonparse / map } \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}
@@ -1619,7 +1636,7 @@
}
% ===
-\cs_new:Npn \__jsonparse_warning_function_expandable:n #1 {
+\cs_new_protected:Npn \__jsonparse_warning_function_expandable:n #1 {
\clist_map_inline:nn {
JSONParseValue ,
JSONParseKeys ,
@@ -1628,9 +1645,11 @@
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 ~ } {
+ \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 }
}
}
@@ -1668,7 +1687,8 @@
__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
+ \keys_set_known:nnnN { jsonparse / store ~ in } {#1}
+ { jsonparse / store ~ in } \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}
More information about the tex-live-commits
mailing list.