I
I
ilysion_in_life2018-04-04 08:50:41
PHP
ilysion_in_life, 2018-04-04 08:50:41

How to decode such JSON?

Hello everyone, guys, help me solve the problem, there is JSON data https://pastebin.com/8A6cZXXy , they are valid, but I can’t understand why the information is not parsed through json_decode(); what did I do wrong as soon as I did not try to always return null?

$file = file_get_contents($_SERVER['DOCUMENT_ROOT'] ."\public\json_update\data.txt");

        $json = json_decode($file, true);

        echo '<pre>';
        var_dump($json);
        echo '</pre>';

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nick Sdk, 2018-04-04
@ilysion_in_life

1. look at the encoding of the file '\public\json_update\data.txt'
1.1 you probably have a data.txt file in an encoding other than UTF-8 , more precisely even UTF-8 (without BOM)
2. see if the content is correct in $file

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question