PHP – json_decode return null

  • PHP 에서 분명히 json형식에 string인데 json_decode가 null 일경우
$table = file_get_contents("table/test.json");
var_dump($table);

$table = preg_replace("#(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/)|([\s\t]//.*)|(^//.*)#", '', $table);
$table = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $table);

$json_a = json_decode($table, TRUE);
  • 알수는없지만 json 파일 만들때 BOM형식이나 \n이 들어갈수있음

Published by

shotan

Hi i'm cho

Leave a Reply

Your email address will not be published. Required fields are marked *