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: |
Description
In jQuery.ajax.httpData, would you consider using the native JSON support (http://www.json.org/js.html) if available? Below is some untested sample code. Maybe the (JSON && JSON.parse) check is better located under jQuery.support.JSON 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); else data = window["eval"]("(" + data + ")");
Attachments (0)
Change History (5)
Changed March 26, 2009 10:23PM UTC by comment:1
cc: | → hakanson, flesler |
---|---|
resolution: | → invalid |
status: | new → closed |
Changed March 26, 2009 10:45PM UTC by comment:2
resolution: | invalid |
---|---|
status: | closed → reopened |
Native JSON parse and stringify will be a built-in browser feature in Firefox 3.1 and IE8. That json.org link just referenced a compatible library. Sorry for the confusion, but I think it is a legitimate request and has a performance advantage.
http://ajaxian.com/archives/native-json-in-firefox-31-joins-ie-8
Changed March 27, 2009 02:44PM UTC by comment:3
owner: | → flesler |
---|---|
status: | reopened → new |
Then we probably will add compatibility with it once it's established.
Changed May 20, 2009 09:29PM UTC by comment:4
resolution: | → fixed |
---|---|
status: | new → closed |
Fixed in SVN rev [6361].
Changed May 22, 2009 02:42AM UTC by comment:5
Line 503 of ajax.js should probably be changed to:
if ( type === "json" ) {
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: http://dev.jquery.com/ticket/3231