How to create json parser with javascript


Go to and download and print the state machine diagram.

Ignore the Unicode and escaped characters on strings, and the ieee number format for now.

Now look again at it. It’s a quite simple state machine. Read one char, skip spaces if any, pick the char, read the Boolean, number, string, or if an array or map, recurse.

Focus on the state machine first. Then the escaped chars, then on the ieee numbers, and maybe then the Unicode chars. These three are each as complicated as the remaining whole parser, so don’t try to do everything at the same time.

(Visited 44 times, 1 visits today)