PHP: file_get_contents('php://input') returning string for JSON message
Your use of json_decode
is creating an associative array, not an object. You can treat it like an array, instead of an object. If you want an object, use this, instead:
$obj = json_decode($json);
See the documentation on the second parameter to json_decode()
:
assoc When TRUE, returned objects will be converted into associative arrays.
Also, as Johannes H. pointed out in the comments, the output of echo $json;
indicates that you are not actually receiving JSON, in the first place, so you will need to address that, as well. You asked why it isn't JSON; without seeing how you are requesting this script, it's impossible to say for sure.