如何在php中解码json文件

时间:2016-07-14 09:59:41

标签: php json decode

我正在尝试解码这个json文件

{"name":"apple","price":1.2312312331231232e 23,"qty":-1,"num":5,"color":"","category":"FRUITS","_id":"VZbGneNygMKYCijr"}\n{"name":"orange","price":12,"qty":-7,"num":2,"color":"","category":"FRUITS","_id":"d892zf2ccyNlPAZM"}\n{"name":"apple","price":12,"qty":-5,"num":4,"color":"","category":"FRUITS","_id":"dja3UQ7vBUs1xBHw"}\n{"name":"apple","price":12,"qty":-7,"num":1,"color":"","category":"FRUITS","_id":"yZc1lMB0SKoSIsxw"}\n{"name":"apple","price":12,"qty":-8,"num":3,"color":"","category":"FRUITS","_id":"yyPn4UcDin6uAY52"}\n

1 个答案:

答案 0 :(得分:1)

有很多方法可以读取文件,让我们说file_get_contents()

$file = file_get_contents('FILE WITH FULL PATH');

$decoded = json_decode ($file);

var_dump($decoded);

你没事。