0

I am unable to decode Json on PHP, it returns NULL if I do a json_decode()

If I do a var_dump it give me the following json string:

array(12)
{
    ["Type"]=> string(5) "Test"
    ["PIN"]=> int(0)
    ["OwnerId"]=> string(36) "3809fcad-bbcb-4ae2-af48-306565dc13f5"
    ["Name"]=> string(22) "Dummy Simulator Device"
    ["IgnitionOn"]=> NULL
    ["LastGPSEvent"]=> string(36) "87907b6b-4e0b-4726-853c-0fd9777ee764"
    ["CurrentTrip"]=> string(36) "d94c0730-e78b-46df-8001-a94d76113571"
    ["LastContactTime"]=> string(24) "2013-07-12T15:27:04.534Z"
    ["Viewers"]=> NULL
    ["_id"]=> string(28) "SimTest_LLTmkJ3EIavH2RKKYkVf"
    ["_rev"]=> NULL
    ["_deleted"]=> bool(false)
}
2
  • 1
    Json is essentially a string. json_decode() converts the string into an array or StdClass. What you posted is already an array. So where is the json string? Commented Jul 12, 2013 at 16:58
  • 2
    Your var_dump looks like it is working for a PHP array. If the var is already a PHP array, you wouldn't need to use json_decode(). Can you post the actual code that gives your result? Commented Jul 12, 2013 at 16:58

1 Answer 1

4

That is not JSON.

That is already PHP array -- no need to decode anything.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.