Is JSON.stringify () reliable for serializing JSON objects?
I need to send complete objects from Javascript to PHP. It seemed pretty obvious to do JSON.stringify () and then json_decode () at the end of PHP, but would that allow strings with ":" and ","? Do I need to run the escape () function on large user input strings, which might be causing the problem? What would this evacuation function be? I don't think escaping works for my purposes.
Are there any downsides to JSON.stringify () I need to know?
thanks
a source to share
Yes, it's reliable in any decent implementation (like Crockford's ), and no, you don't have to run it through escape
first (if you do, PHP will be pretty confusing on the other end). Browsers are starting to get their own JSON applications (now that it's in the fifth version of the spec ), but for now you may be the best using Crockford or similar.
a source to share
There is a pretty good description of what JSON.stringify () does here:
Source code is also available if you want to be sure and / or make changes.
I have been using it for several months with no problem.
Also, I'm not sure if you saw the man page for json_decode, there is a lot of good information there: http://ie2.php.net/manual/en/function.json-decode.php
NTN
a source to share