PHP parsing JSON response {"errors":[{"message":"msg here","code":34}]}
How do I deal with this JSON response?
{"errors":[{"message":"msg","code":34}]}
Ideally I can do things like:
<?php
$response = '{"errors":[{"message":"msg","code":34}]}';
$decode = json_decode($response);
echo $decode->errors->message; // error 'Notice: Trying to get property of
non-object'
Or, this:
<?php
echo $decode->errors['message'] // error 'Notice: Undefined index: message'
But that's clearly not the right way.
How do I access the error message?
No comments:
Post a Comment