JSON checker

Featuring the Dragonfly web framework
Posts: 72
Joined: Sun Sep 13, 2009 5:38 am
Location: Japan

JSON checker

Post by kosh »

This test code is based on JSON Checker (http://www.json.org/JSON_checker/)

json-test.lsp: http://pastebin.com/9nqJHSW3

The results are here:

Code: Select all

> newlisp -v
newLISP v.10.5.2 32-bit on Win32 IPv4/6 UTF-8 libffi.

> newlisp json-test.lsp
fail1.json -> pass : "A JSON payload should be an object or array, not a string."
fail7.json -> pass : ["Comma after the close"],
fail8.json -> pass : ["Extra close"]]
fail10.json -> pass : {"Extra value after close": true} "misplaced quoted value"
fail13.json -> pass : {"Numbers cannot have leading zeroes": 013}
fail15.json -> pass : ["Illegal backslash escape: \x15"]
fail17.json -> pass : ["Illegal backslash escape: \017"]
fail18.json -> pass : [[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]
fail25.json -> pass : ["	tab	character	in	string	"]
fail26.json -> pass : ["tab\   character\   in\  string\  "]
fail27.json -> pass : ["line
fail28.json -> pass : ["line\
However, this is strictly data. I think current json-parse is enough to use.

PS. A strange things, fail18.json also passes on JSONLint (http://jsonlint.com/).