wangxiaowei0303 / rapidjson

Automatically exported from code.google.com/p/rapidjson
MIT License
0 stars 0 forks source link

Add support for 'relaxed' JSON syntax. #37

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I understand the main purpose of rapidjson is to comply exactly to JSON RFC, 
but in some case, using rapidjson to parse 'javascript object syntax' would be 
usefull too.

I'm not an expert, but afaik the main differences I see are:

1- key of each attribute may not be sourrounded with quote

2- string quotes can be both simple quote (') or double quote ("). In case of 
double quote, the simple quote has not to be escaped, and in case of simple 
quote, the double quote has not to be escaped.

3- there are constraints on key names (no whitespace in them, not beginning 
with a digit, ...)

That way, a string like the following would become parsable without error:

    { a:'titi', b:27, bcd :[1,2], abc : {x:12,y:12,z: 12  } }

I did a first try covering points 1 and 2 above ; you'll find it as attachement 
(only reader.h has been patched). It's just a try, nothing polised here. For 
example, a flag should obviously be added in the parser to allow (or not) such 
'relaxed' syntax and there are probably performance caveheats.

BTW, really nice lib ; thanks for sharing :-)

Original issue reported on code.google.com by noukn...@gmail.com on 4 Sep 2012 at 8:42

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by milo...@gmail.com on 12 Nov 2012 at 2:16

GoogleCodeExporter commented 9 years ago
This issue has been merged to https://github.com/miloyip/rapidjson/issues/36 
for further discussion.

Original comment by milo...@gmail.com on 13 Jul 2014 at 4:36