Answer the question
In order to leave comments, you need to log in
What is wrong with encoding when parsing json from 1C to php?
There are the following lines:
//$json = '[{"sku":"5200001200057","model":"516187A"},{"sku":"5200001200002","model":"521387"}]'; // work typed manually as prospekt.json
$json = '[{"sku":"5200001200057","model":"516187A"},{"sku":"5200001200002","model":"521387"}]'; // prospekt.json not work
$res = json_decode($json, true); // возвращает NULL
switch (json_last_error()) {
case JSON_ERROR_NONE:
echo ' - Ошибок нет';
break;
case JSON_ERROR_DEPTH:
echo ' - Достигнута максимальная глубина стека';
break;
case JSON_ERROR_STATE_MISMATCH:
echo ' - Некорректные разряды или не совпадение режимов';
break;
case JSON_ERROR_CTRL_CHAR:
echo ' - Некорректный управляющий символ';
break;
case JSON_ERROR_SYNTAX:
echo ' - Синтаксическая ошибка, не корректный JSON';
break;
case JSON_ERROR_UTF8:
echo ' - Некорректные символы UTF-8, возможно неверная кодировка';
break;
default:
echo ' - Неизвестная ошибка';
break;
}
Answer the question
In order to leave comments, you need to log in
When pasted into the ideone editor, it turned out that there are some artifacts in your json-e))
Remove artifacts and voila https://ideone.com/YlDWAx
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question