Skip to main content

Bug Tracker

Side navigation

#4429 closed enhancement (fixed)

Opened March 26, 2009 05:26PM UTC

Closed May 20, 2009 09:29PM UTC

Last modified March 13, 2012 04:55PM UTC

Use native JSON.parse if available inside ajax.httpData

Reported by: hakanson Owned by: flesler
Priority: minor Milestone: 1.4
Component: ajax Version: 1.3.2
Keywords: JSON Cc: hakanson, flesler
Blocked by: Blocking:

In jQuery.ajax.httpData, would you consider using the native JSON support ( if available? Below is some untested sample code. Maybe the (JSON && JSON.parse) check is better located under and could be expanded to check if JSON.parse is a function?

// Get the JavaScript object, if JSON is used.

if ( type == "json" )
	if (JSON && JSON.parse)
		data = JSON.parse(data);
		data = window["eval"]("(" + data + ")");
Attachments (0)
Change History (5)

Changed March 26, 2009 10:23PM UTC by flesler comment:1

cc: → hakanson, flesler
resolution: → invalid
status: newclosed

We don't rely on this kind of things, only built-in browser features like querySelectorAll.

You can always add it for yourself using $.ajax's 'dataFilter' setting added since 1.3.

More here:

Changed March 26, 2009 10:45PM UTC by hakanson comment:2

resolution: invalid
status: closedreopened

Native JSON parse and stringify will be a built-in browser feature in Firefox 3.1 and IE8. That link just referenced a compatible library. Sorry for the confusion, but I think it is a legitimate request and has a performance advantage.

Changed March 27, 2009 02:44PM UTC by flesler comment:3

owner: → flesler
status: reopenednew

Then we probably will add compatibility with it once it's established.

Changed May 20, 2009 09:29PM UTC by john comment:4

resolution: → fixed
status: newclosed

Fixed in SVN rev [6361].

Changed May 22, 2009 02:42AM UTC by pbcomm comment:5

Line 503 of ajax.js should probably be changed to:

if ( type === "json" ) {