#7572 closed bug (invalid)
parseJSON throws invalid JSON exception on valid JSON
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | 1.5 |
Component: | unfiled | Version: | 1.4.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
here is the original JSON:
{ 'content' : [ {'id':1,'name':'Personal Information','len':3}, {'id':2,'name':'Income','len':2}, {'id':3,'name':'Family','len':2}, {'id':4,'name':'Child I','len':3} ]}
here the original error:
Error: uncaught exception: Invalid JSON: {'content' : [{'id':1,'name':'Personal Information','len':3},{'id':2,'name':'Income','len':2},{'id':3,'name':'Family','len':2},{'id':4,'name':'Child I','len':3}]}
I got the same error on FF3.6, Chrome7 and IE7.
Note: See
TracTickets for help on using
tickets.
Thanks for taking the time to contribute to the jQuery project by writing a bug ticket and providing a testcase!
This isn't valid JSON so there is no bug. JSON requires you to use double quotes for strings. The use of single quotes isn't a valid option.
Please check http://www.json.org/.
I assume this happened because you are hand-crafting your JSON strings. Don't do that. Code for generating JSON data is available for a large variety of programming languages. http://www.json.org/ also provides a comprehensive listing of existing JSON libraries, organized by language.
The next time please use the jQuery Forum for support requests when you aren't sure there is really a bug in jQuery core.