Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse Json string

Status
Not open for further replies.

junkie8

Technical User
Aug 9, 2009
32
US
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?
 
Apparently nothing is wrong. However without seeing the code in context its hard to say.

Clearly something is happening between the file_get_contents call and the json_decode call.

So what happens between them?

Heck you could call json_decode on the string you posted and it works fine.

So clearly there's something else going on in the code.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top