Parsing multiple JSON Objects from a single file in PHP -
i need extract object id total_time file containing multiple json objects
{"alternative_names":[["",""]],"route_name":["",""],"status_message":"found route between points","route_geometry":"qo{`o@wpslhbmfzwepbgdzdeblfwdgv@`g`czeybfiyeteonteumpauhkascgc[mb{agcua{@uca@}cl@ybtb}@ldvhecatdmcdbcdx@iddedk@ubebeb_ccgcxyfi^{dg\\wbkp_fs^wbis_ce[_d}uwackibqigi_telaucmmp_ishqf@_wyjee}f`mkdjiitth@y|@lobq^vy@mu@fw@cuxoco@r^gb@zroojpsbfmq@rmjbdpnepklenh`j~dvn@la@nd@pt|f@llv_@przlbhnb@fuxc@lmnac~zancbxna`kb|bb`|cbmcl]ry`xczkcjwbzobjxgl_g|fnhcmf~e~me~pft}ejbblzahvinyhfqdb~cbla`w@poazt@z}@bb@did~dbxtejgcfjdljbpuafw@bpgngdhqf~yc~g@la@v~@ni@rbajg@jp`jlc`fnddgddu@j@eahba@lcldcacji_btcy@va_dvf}qaf}bof@l{@{cnfokdr}ma`xbgm|tkjxpmllssf@|}@gf@`x@kozxmefgmsx^kf@tw@mdtl}k@r~@ykcjjeau@niaee@bu@uul\\}dpfzcrcr|@dt@|nblrobx_bdzlv|dbd`pbr~anq@xm@r|@ls@|y@dq@}o`xum`qcdheobgbeccu[xxmbh","route_summary":{"end_point":"","start_point":"","total_time":824,"total_distance":15391},"found_alternative":true,"alternative_summaries":[{"end_point":"","start_point":"","total_time":886,"total_distance":14967}],"via_points":[[25.196808,55.273754],[25.139168,55.187702]],"status":0,"via_indices":[0,144],"hint_data":{"locations":["tdmlap____8aaaaadwaaaa8aaaa9aaaabaaaaotwbgaaaaaacxmaarxpswmeaaeb","4q4aagkybgaaaaaacqaaaaaaaaahaqaaaaaaaguyaaaaaaaa4zd_afgysgmgaaeb"],"checksum":326195011},"alternative_geometries":["qo{`o@wpslhbmfzwepbgdzdeblfwdgv@`g`czeybfiyeteonteumpauhkascgc[mb{agcua{@uca@}cl@ybtb}@ldvhecatdmcdbcdx@iddedk@ubebeb_ccgcxyfi^{dg\\wbkp_fs^wbis_ce[_d}uwackibqigi_telaucmmp_ishqf@_wyjee}f`mkdjiitth@y|@lobq^vy@ec@vfayeafccok@vta}wtx@us|d@skavfcgexjgjptqh|o}`@n~@wsve@qehkkydp@gb~duurk@_jdrsahdmjlvqd@rcaum|zeg@zkaikzugibs}b~etdvbhr@`a@dq~j|rbpmaj_cfyalazd^ldghnoyqlg@w[l|@}q~d@ebb}af@madaw@bbwpbjrbn@hbaajgif@ptak^rmaovxy@chjpmc`h`e|bp[xrpc@`zflvizllireg~cejrarz@rmal|@lbdrzbjwlq|xa~baho@pc@d_@jwng@j^hnzjvgnenpjllax@lgahv@bgvcjkbvoabjdr}bvfax{@t\\rsfodvic~zajgafoxivabajwctsbv|@|m@bd|bvl`id_dt|btllixsax_afe~crn@hc@rkvih_bniape@z\\xipgtobpxateddrqrmzjchlb`~@lo@nwf`pe|jbl|azfze|dfdvdrcjkfjr`@n\\plzk`nbzzado~lhafxaezcdcnlpkbp@ti@nijhdrzmjo@tg@~mvkpwctdclw@bm@z[bwfr@vk@zcrcr|@dt@|nblrobx_bdzlv|dbd`pbr~anq@xm@r|@ls@|y@dq@}o`xum`qcdheobgbeccu[xxmbh"],"alternative_indices":[0,183]} {"hint_data":{"locations":["axqdap____8aaaaabwaaabeaaaayaaaaiwiaaerwagaaaaaadgycaef7tamcaaeb","bosdap____8aaaaaawaaaacaaadfaqaafaaaaejwagaaaaaanqecadzdtamfaaeb"],"checksum":326195011},"route_name":["",""],"via_indices":[0,15],"via_points":[[25.299982,55.376873],[25.29874,55.369179]],"found_alternative":false,"route_summary":{"end_point":"","start_point":"","total_time":101,"total_distance":871},"route_geometry":"{_ego@m}|rhbpbabvhuc`euareutetaldvend`mldvmli@hseffzn@qltgnhwcs@fkwbjf","status_message":"found route between points","status":0}
and using script,
<?php $data = file_get_contents('sample.json'); $data = json_decode($data); $totaltime = $data->route_summary->total_time; var_dump($totaltime); ?>
but gives me null output.any help,would appreciated?
the value can retrieved by,
$totaltime = $data['route_summary']['total_time'];
if json pass $data
formatted.
Comments
Post a Comment