I have seen references to some browsers natively supporting JSON parsing/serialization of objects safely and efficiently via the window.JSON
Object, but details are hard to come by. Can anyone point in the right direction? What are the methods this Object exposes? What browsers is it supported under?
views:
1675answers:
1
+6
A:
Internet Explorer 8 and the latest beta of Firefox (to be version 3.5) support native JSON parsing, but that's it, so I wouldn't count on it.
Links:
musicfreak
2009-05-21 03:40:06
I know the support is not widespread, but using this method should be a lot faster and safer than eval()ing a string, so I want to use it where it's available. Any idea on support from other browsers?
levik
2009-05-21 03:53:50
I didn't say don't use it, I said don't count on it. Definitely check to see if it's available (at this point only IE8 and the few Fx Beta users) and use it if so, but I'm just saying that you shouldn't assume the browser supports it. As of now, those two are the only browsers that support it, and WebKit is working on it right now, so it'll probably be in Google Chrome and Safari sometime soon.
musicfreak
2009-05-21 04:00:25
Oh, and on a side note, NEVER eval() JSON strings. Instead, use one of the many JSON parsing libraries available.
musicfreak
2009-05-21 04:08:17
Of the "many" libraries available, are they any preferred? Is the one at http://www.json.org/json2.js generally the most used? I noticed references to it in jQuery 1.4 source.
colbeerhey
2010-02-06 01:20:17
@colbeerhey: Yeah, that's the one I see most often. You could also steal jQuery's.
musicfreak
2010-02-06 08:03:41
http://code.google.com/chrome/extensions/faq.html#faq-dev-07 - Google Chrome supports natively. I don't know how long is it.
MartyIX
2010-05-02 18:12:25