67

Possible Duplicate:
Serializing to JSON in jQuery

I'm using jquery as a library in my javascript code. But sometimes I have to JSON.stringify().

When I want to keep my code IE compatible I use
$("head").append('<script type="text/javascript" src="../Includes/json2.js"></script>');
to get my JSON.stringify() to work. Isn't there a equivalent in jquery for JSON.stringify()?

Community
  • 1
  • 1
Highmastdon
  • 6,960
  • 7
  • 40
  • 68
  • 7
    IE8 and higher natively supports the `JSON.stringify` method. IE7 and lower is not something that you should use. And if for some reason you need to support such legacy crap all you need to do is include the json2.js script to your page (as seemingly you have already done). – Darin Dimitrov Jun 20 '12 at 11:56

1 Answers1

68

There is no such functionality in jQuery. Use JSON.stringify or alternatively any jQuery plugin with similar functionality (e.g jquery-json).

Mariusz Jamro
  • 30,615
  • 24
  • 120
  • 162