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.

3
  • JSON.stringify Commented Aug 30, 2015 at 4:10
  • Also see Serializing to JSON in jQuery Commented Aug 30, 2015 at 4:28
  • 1
    exist other solution without use JQuery? Commented Aug 30, 2015 at 4:30

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

it works well, thanks
Please don't copy other answers. If the question is a duplicate, vote to close it as such.