This seems like a pretty basic question, but it has me stumped.

Here's my scenario: I'm using Douglas Crockford's JSON2.js to parse an
object in JavaScript, which I then pass to a PHP script to store in a
file. I use JSON.stringify() on the object, which logs to the console
as this:

{"employees":{"data":{"John":{"fname":"John","lname":"Doe","city":"Toronto","country":"Canada"}}}}

Then I use the jQuery POST function to send it to a PHP script. Before
doing anything with it in PHP, I log the received value to the
console, and this is what I get:

{\"employees\":{\"data\":{\"John\":{\"fname\":\"John\",\"lname\":\"Doe\",\"city\":\"Toronto\",\"country\":\"Canada\"}}}}

The problem is, when I call the script to retrieve this data from a
file, JSON.parse can't parse it because of the back-slashes. I'm
pretty sure my problem is on the PHP side (since it's fine coming out
of JS); what do I need to do to fix this? is a preg_replace enough?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to