I need to send full objects from Javascript to PHP. It seemed pretty obvious to do JSON.stringify() and then json_decode() on the PHP end, but will this allow for strings with “:” and “,”? Do I need to run an escape() function on big user input strings that may cause an issue? What would that escape function be? I don’t think escape works for my purposes.
Are there any downsides to JSON.stringify() I need to know about?
Thanks
Yes, it’s reliable in any decent implementation (like Crockford’s), and no, you don’t have to run it through
escapefirst (if you do that, PHP will be pretty confused at the other end). Browsers are starting to get their own implementations of JSON stuff (now that it’s in the 5th edition spec), but for now, you may be best off using Crockford’s or similar.