2

I downloaded the code from json.org to serialize/deserialize javascript objects to/from json and it worked just fine. However, in production, it conflicts with my other javascript code apparently because it uses for in loops. Is there another library that does this? Thanks!

4
  • How does using for conflict with your code? Commented Jun 30, 2009 at 17:29
  • 2
    Yeah, I want to know the answer to that, too. You must have some code that adds junk to native objects? Nasty. Commented Jun 30, 2009 at 17:39
  • 1
    I think Nosredna nailed it. It sounds like you might be modifying the Object.prototype object... Big bad voodoo. Commented Jun 30, 2009 at 20:45
  • There is JSON.stringify and JSON.parse Commented Apr 4 at 7:22

2 Answers 2

2

I use jQuery, specifically with the jQuery-JSON plugin. As you can see from the link, this works like so

var thing = {plugin: 'jquery-json', version: 1.3};
var encoded = $.toJSON(thing);              //'{"plugin": "jquery-json", "version": 1.3}'
var name = $.evalJSON(encoded).plugin;      //"jquery-json"
var version = $.evalJSON(encoded).version;  // 1.3
Sign up to request clarification or add additional context in comments.

Comments

0

Have you looked at the YUI JSON utility?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.