Created
October 27, 2016 06:08
-
-
Save porglezomp/4b42d1841511bb983f32dba0cc032175 to your computer and use it in GitHub Desktop.
It's possible to have an extremely simple standard-conformant JSON parser!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RFC 7159 § 9 | |
# "An implementation may set limits on the size of texts that it accepts." | |
def parse_json(text): | |
if len(text) != 1: | |
raise ValueError("Only accepts single character JSON values") | |
return int(text[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment