3

When you serialise a form using jQuery.serialize(), the method will serialise the form fields and its values so you can submit to the server. Is there a method/function that would do the same with a javascript object instead of a form?

WagnerMatosUK
  • 4,309
  • 7
  • 56
  • 95
  • http://stackoverflow.com/questions/6487699/best-way-to-serialize-unserialize-objects-in-javascript –  Jan 01 '14 at 15:35

2 Answers2

4

Check out JSON.stringify.

JSON.stringify({x: 5, y: 6}); // '{"x":5,"y":6}' or '{"y":6,"x":5}'
Dan Abramov
  • 264,556
  • 84
  • 409
  • 511
2

You're looking for the jQuery.param function.

Bergi
  • 630,263
  • 148
  • 957
  • 1,375