user2242590
user2242590

Reputation: 29

JSON String not parsing correctly PHP

I get the following output from an API call:

$json = file_get_contents($service_url);

the var_dump of $json gives me:

string(308) " [{"Transaction_ID":2805579},{"Transaction_ID":2777876},{"Transaction_ID":2808406}]"

However, var_dump(json_decode($json)) returns a null.

What am I doing wrong?

Upvotes: 1

Views: 46

Answers (1)

Armand
Armand

Reputation: 215

See: http://php.net/manual/en/function.json-decode.php

decode_json isn't a function, you should use json_decode

var_dump(json_decode($json))

Upvotes: 1

Related Questions