1

I need to serialize an object to JSON, in javascript. How I can do it? I google it, but im not found the solution.

All the response are "You mustn't serialize Json in javascript, you must serialize in other language as Java, C#, so on"

Without use JQuery.

1 Answers1

3

Checkout JSON.stringify() and JSON.parse() in JSON2 documentation

Example:

myData = JSON.parse(text); // from json string to js object

var myJSONText = JSON.stringify(myObject, replacer); // js object to json string

if you want to know about more checkout this link Serializing to JSON in jQuery

Community
  • 1
  • 1
Vignesh Shiv
  • 1,129
  • 7
  • 22
  • 1
    it works well, thanks –  Aug 30 '15 at 04:20
  • 1
    Please don't [copy other answers](http://stackoverflow.com/questions/9292823/serialize-javascript-object-to-json-and-back). If the question is a duplicate, vote to close it as such. – Jonathan Lonowski Aug 30 '15 at 04:20