[jQuery] Properties escaped when sending JSON to PHP?

[jQuery] Properties escaped when sending JSON to PHP?


Hi there,
I've just spent an hour trying to figure out why my JSON didn't work
on my server. It works now, but I'm a bit confused about the solution
- maybe you guys have som input:
My Object:
var example = {
id: 1,
title: "JSON Möchtegern"
}
I use the json2.js from www.json.org:
json = JSON.stringify(example);
This produces a seemingly correct "JSON-string":
{"id":"1", "title":"JSON Möchtegern"}
I then send my data with $.ajax, using Type: Post.
Firebug tells me the string still looks like the one above.
But when processing it with (PHP) json_decode($_POST['json'] the only
response I got was an annoying "NULL".
So I checked the string and it now looked like this:
{\"id\":\"1\", \"title\":\"JSON Möchtegern\"}
So I ended up str_replace:ing all the \'s out of there and now it
works.
But for all of you patient enough to read this long post, here's my
question:
Are you really supposed to replace all the \'s on the server side, or
is there some option I'm missing in my AJAX-call? contentType?
Thanks!
Mickster