Possible Duplicate:
Can't decode JSON string in php
I’m at my wits end here, and I can’t figure it out.
My code was working correctly locally (using xamp) but now it won’t work.
When I run this code:
echo "passed in parameter" . $_POST["jsoned"];
$unjasoned = json_decode("[\"23\",[],[[\"a@a.a\",\"2011-01-08\"]]]");
die("\ntype\n\t". gettype($unjasoned) . "\n\n\nAmount\n\t" . $unjasoned[0]);
I get:
passed in parameter[\"23\",[],[[\"a@a.a\",\"2011-01-08\"]]]
type
array
Amount
23
Which is exactly what i want
However the problem happens when I use the passed variable in $_POST["jsoned"] which is you see in the result above is obviously exactly the same as what im manually inserting here.
so if i do this instead (same exact input):
echo "passed in parameter" . $_POST["jsoned"];
$unjasoned = json_decode($_POST["jsoned"]);
die("\ntype\n\t". gettype($unjasoned) . "\n\n\nAmount\n\t" . $unjasoned[0]);
I get:
passed in parameter[\"23\",[],[[\"a@a.a\",\"2011-01-08\"]]]
type
NULL
Amount
so…… WHAT THE HELL IS HAPPENING?! PLEASE if you have any hints share them with me, ill be eternally thankful.
ps. my server runs php version 5.2.13
answered already here Can't decode JSON string in php