I’m using jQuery.
serialize seems not fit for this job.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The only serialisation on ‘arbitrary objects’ is
toStringas described by thenduks. This is a convenience serialisation for display purposes only (and even then very often generates useless string representations like[object Object]).Not reliably, no.
If the datatypes you need to serialise are just the JS builtins like Array, String, Number and unprototyped Object being used as a transparent mapping, you can use JSON. Call
JSON.stringify(obj)to serialise,JSON.parse(str)to re-parse. Use json2 or some other library with JSON features to support old browsers that don’t have native JSON.But ‘arbitrary objects’? No, can’t be done (not in most other languages either).