Bug Tracker

Ticket #7572 (closed bug: invalid)

Opened 4 years ago

Last modified 3 years ago

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:
Blocking: Blocked by:

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.

Change History

comment:1 Changed 4 years ago by jitter

  • Status changed from new to closed
  • Resolution set to invalid

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 4 years ago by jitter (previous) (next) (diff)
Note: See TracTickets for help on using tickets.