Rationale behind the JSON -> CJSON switch in Sugar codebase?
Martin Langhoff
martin.langhoff at gmail.com
Thu Nov 12 10:57:16 EST 2009
On Thu, Nov 12, 2009 at 4:40 PM, Tomeu Vizoso <tomeu at sugarlabs.org> wrote:
> Is because of a bug in cjson why those files aren't being parsed?
CJSON is not a vanilla parser. It makes a very "strict" reading, that
- throws an exception on unordered keys
- throws an exception on random whitespace (that is allowed by JSON)
- reads redundant escapes (backspaces) literally -- normal json
parsers read "foo/bar" and "foo\/bar" both to "foo/bar", because the
'/' doesn't need escaping. CJSON reads it to 'foo\/bar' which violates
the spec
This last problem means that the JEB parser gets the mimetype wrong
from files produced by Moodle.
But even "formatting" spacing in a JSON file make CJSON throw fits.
This is on purpose, because CJSON was created to remove all ambiguity
and flexibility from the JSON spec, so that for any given data
structure there is only one true way to represent it.
This has clear benefits for data that will be signed
cryptographically. But is a disaster for interop.
More info on CJSON at http://wiki.laptop.org/go/Canonical_JSON
m
--
martin.langhoff at gmail.com
martin at laptop.org -- School Server Architect
- ask interesting questions
- don't get distracted with shiny stuff - working code first
- http://wiki.laptop.org/go/User:Martinlanghoff
More information about the Devel
mailing list