You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, thanks for the excellent article JSON Parser with JavaScript. I like the straightforward and easy to understand code, and it was faster than my original code. I used it as a basis to simplify and improve my own lossless-json parser , the parse code in v2 code is largely yours 😄 .
The full CodeSandbox example in the article contains a bug though when parsing escaped control characters like \n and \t (line 100-111). These are replaced with regular word characters n and t instead of the real control characters:
if(str[i]==="\\"){constchar=str[i+1];if(char==='"'||char==="\\"||char==="/"||char==="b"||char==="f"||char==="n"||char==="r"||char==="t"){result+=char;// Oops! Here we should append the real control characteri++;}
In lossless-json I solved this by having a map escapeCharacters and using the value from the map, holding the real control characters, see code:
First, thanks for the excellent article JSON Parser with JavaScript. I like the straightforward and easy to understand code, and it was faster than my original code. I used it as a basis to simplify and improve my own
lossless-json
parser , theparse
code in v2 code is largely yours 😄 .The full CodeSandbox example in the article contains a bug though when parsing escaped control characters like
\n
and\t
(line 100-111). These are replaced with regular word charactersn
andt
instead of the real control characters:In
lossless-json
I solved this by having a mapescapeCharacters
and using the value from the map, holding the real control characters, see code:The text was updated successfully, but these errors were encountered: