So I have a json file inside my folder, but I cannot read it because it need an empty line at the end, how to solve that ?
I read my json in PHP using this :
$string = file_get_contents('ideb/NPWP.txt');
$json_a = json_decode($string, TRUE);
echo $json_a['header']['kodeReferensiPengguna'];
My json :
{
"header": {
"kodeReferensiPengguna": "",
"tanggalHasil": "",
"idPermintaan": "",
"idPenggunaPermintaan": "",
"dibuatOleh": "Dyta Alldilah",
"kodeLJKPermintaan": "",
"kodeCabangPermintaan": "",
"kodeTujuanPermintaan": "",
"tanggalPermintaan": "",
"totalBagian": "1",
"nomorBagian": "1"
}
}
If I add newline at the bottom of the json there is no error
{
"header": {
"kodeReferensiPengguna": "",
"tanggalHasil": "",
"idPermintaan": "",
"idPenggunaPermintaan": "",
"dibuatOleh": "Dyta Alldilah",
"kodeLJKPermintaan": "",
"kodeCabangPermintaan": "",
"kodeTujuanPermintaan": "",
"tanggalPermintaan": "",
"totalBagian": "1",
"nomorBagian": "1"
}
}
NOTE : My json file format is .txt