Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 11 years ago

#6267 closed bug (worksforme)

parseJSON - plain boolean and integers

Reported by: gregor Owned by:
Priority: Milestone: 1.4.3
Component: core Version: 1.4.2
Keywords: json, parseJSON, true, integer Cc:
Blocked by: Blocking:


The code bellow should produce one success alert (for first item) and three alerts for failed attempts (last three items). But it ain't so: it produces success alerts for the last two items.

I searched the web and json.org and I couldn't find logical explanation, so I am filling this as a bug.

var a = new Array();
a[0] = '{ "fridge": "beer" }';
a[1] = "pizza";
a[2] = "true";
a[3] = "1";

for (var i = 0; i < a.length; i++) {
	try {
		var b = jQuery.parseJSON(a[i]);
		alert("Parsing \"" + a[i] + "\" was success.");
	} catch(e) {
		alert("Parsing \"" + a[i] + "\" failed.");

Change History (1)

comment:1 Changed 13 years ago by john

Component: unfiledcore
Resolution: worksforme
Status: newclosed

This is matching the spec. Just try using the JSON parser provided by the browser:


It will alert out 'true'.

Note: See TracTickets for help on using tickets.