Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#7572 closed bug (invalid)

parseJSON throws invalid JSON exception on valid JSON

Reported by: birk.brauer@… Owned by:
Priority: undecided Milestone: 1.5
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:


here is the original JSON:

{ 'content' : [
{'id':1,'name':'Personal Information','len':3},
{'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.

Change History (1)

comment:1 Changed 7 years ago by jitter

Resolution: invalid
Status: newclosed

Thanks for taking the time to contribute to the jQuery project by writing a bug ticket and providing a testcase but this isn't valid JSON. 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/.

A string is a sequence of ... characters, wrapped in double quotes

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.

Version 1, edited 7 years ago by jitter (previous) (next) (diff)
Note: See TracTickets for help on using tickets.