I am stuck with this problem. Here is my code:

```html
<?php 

$arr = [
'from_name' => 'Rosresurs1.ru',
'from_email' => 'team@rosresurs.net',
'reply_email' => 'reply@rosresurs.net',
'subject' => 'Вас приветствует Росресурс!',
'reply_us' => 'Вопрос нам',
'charset' => 'UTF-8',
'headers' => ['List-Unsubscribe: <mailto:support@rosresurs.net?subject=Unsubscribe>, <http://rosresurs.net/escript/unsubscribe.php?token=$token>', 'Precedence: bulk']
];

echo 'Var dump array to encode: <br>';
var_dump($arr);

//Encoding

$done = json_encode($arr, JSON_UNESCAPED_UNICODE);

echo 'Echo encoded array to json: <br><br>';
echo $done . "<br><br><br><br>";

//Decoding

echo "Starting decoding from file: <br><br>";

$var =  json_decode('mailconfig.json', true);
$json_errors = array(
    JSON_ERROR_NONE => 'No error has occurred',
    JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded',
    JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded',
    JSON_ERROR_SYNTAX => 'Syntax error',
);
 echo 'Last JSON error found: ', $json_errors[json_last_error()], PHP_EOL, PHP_EOL . '<br><br>';

echo 'Var dump variable: <br>';
var_dump($var);
```

And here is the output:

[![enter image description here](https://i.stack.imgur.com/hZixw.png)](https://i.stack.imgur.com/hZixw.png)

And here is JSON file, from which I tried to decode json:

```
{"from_name":"Rosresurs1.ru","from_email":"team@rosresurs.net","reply_email":"reply@rosresurs.net","subject":"Вас приветствует Росресурс!","reply_us":"Вопрос нам","charset":"UTF-8","headers":["List-Unsubscribe: , ","Precedence: bulk"]}

```

As you see my array contains UTF-8 symbols, so I have encoded them with JSON\_UNESCAPED\_UNICODE option. But when I try to decode(FROM FILE), it fails. But when I try to decode from encoded variable $done, it works perfectly. 

My json file contains the same $done output(copied from the browser and pasted to file). json\_last\_error said it's a syntax error. But there is no one... 

Also I pasted json string from file to online json syntax verify service and it returned "A valid JSON string".

P.S. I made a lot of echo helpers(see screenshot), so you can get into a problem fast(like starting encoding and decoding points).