Closed jasperhabicht closed 6 months ago
\cctab_const:Nn \c__jsonparse_json_escape_cctab {
\char_set_catcode_other:N b
\char_set_catcode_other:N f
\char_set_catcode_other:N n
\char_set_catcode_other:N r
\char_set_catcode_other:N t
\char_set_catcode_other:N u
}
\str_new:N \l__jsonparse_backspace_str
\str_new:N \l__jsonparse_formfeed_str
\str_new:N \l__jsonparse_linefeed_str
\str_new:N \l__jsonparse_carriage_return_str
\str_new:N \l__jsonparse_horizontal_tab_str
But probably only feasable for file input (or with an environment solution).
A problem is that all letters b
, n
etc. are first parsed as other
, but later only those for the value (but not for the keys) are redefined as letter. JSON only allows \b
, \n
etc. inside strings. \tl_replace_all:
only affects the outer group.
Issue error message if \b
, \n
... are used outside string value?
On the other hand, aren't keys always converted to strings anyways?
JSON allows for
\b
,\f
,\n
,\r
,\t
,\uXXXX
. These escape sequences map to backspace, formfeed, line feed, carriage return, horizontal tab and a unicode character (specified by four hex values) respectively. It is, of course, unclear how exactly these escape sequences should be turned into TeX tokens, except maybe for\uXXXX
which could be turned into the relevant Unicode character.A solution could be to provide for five token variables representing
\b
,\f
,\n
,\r
and\t
repectively which can be assigned strings by the user via key-value settings (defaulting to nothing or spaces maybe). This way, these sequences could at least be read in without much information loss.