Skip to main content

Bug Tracker

Side navigation

#7572 closed bug (invalid)

Opened November 19, 2010 02:36PM UTC

Closed November 19, 2010 02:42PM UTC

Last modified March 14, 2012 08:16PM UTC

parseJSON throws invalid JSON exception on valid JSON

Reported by: birk.brauer@fokus.fraunhofer.de 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.

Attachments (0)
Change History (1)

Changed November 19, 2010 02:42PM UTC by jitter comment:1

_comment0: 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 quotes1290177882823036
_comment1: 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.1290177982052438
resolution: → invalid
status: newclosed

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/.

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.

The next time please use the jQuery Forum for support requests when you aren't sure there is really a bug in jQuery core.