S
S
SHentai2017-07-05 10:23:55
JSON
SHentai, 2017-07-05 10:23:55

Why doesn't JSON_DECODE work?

Hello.
I do it like this:

<?php
$result = json_decode(file_get_contents('http://site.com/')); ## С true так же
echo $result->error;

As a result,
Notice: Trying to get property of non-object in /here/at/us/path/to/root/site/index.php on line 3 I
thought it was a problem with the encoding, converted the string to UTF-8 using mb_convert_encoding, still the same .
The joke is that such a problem is only when I take this one from that site, if I take it from somewhere else, everything is fine.
For example like this:
$result = json_decode('{"status":"ok","data":{"action":"list","email":"[email protected]","mail_cnt":"209","my_cnt":"0","games_cnt":"0","list":["[email protected]"]}}');
echo $result->status;

It works, and if you take it from some other site, too.
There is clearly something with the result from that site, but I can’t understand what.
I hope for your help, thanks.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Semyon Beloglazov, 2017-07-05
@Batlab

Maybe your json does not return error correctly?
Check $result->error with var_dump and write back

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question