I have some some data that I need to send to frontend as array of json objects, it basicly should have same structure as this json:
[{"vin":"U5YFF24128L064909","0":"U5YFF24128L064909","case_id":"1462538","1":"1462538","claimnumber":"E140039698","2":"E140039698","platenumber":"5M47465","3":"5M47465","axrmrs_id":"2051707","4":"2051707","insurer_memberid":"MM-O-8AB24F6D-1","5":"MM-O-8AB24F6D-1","country":"CZ","6":"CZ","date_created":"2014-02-10 00:00:00","7":"2014-02-10 00:00:00","totalloss":"N","8":"N","lastcalc_manufacturer_code":"28","9":"28","lastcalc_model_code":"25","10":"25","lastcalc_submodel_code":"07","11":"07","audavin_triggered":"","12":"","accident_date":"2014-02-02 00:00:00","13":"2014-02-02 00:00:00","registration_date":"2008-04-28 00:00:00","14":"2008-04-28 00:00:00","manufacturing_year":"2008","15":"2008","spareparts":"26573.4","16":"26573.4","totalcosts":"42187.47","17":"42187.47","laborhours":"7.3","18":"7.3","laborcosts":"3577","19":"3577","calculationdate":"2014-02-22 23:02:00","20":"2014-02-22 23:02:00","paintlabor":"5995","21":"5995","paintmaterial":"6042.07","22":"6042.07","currency":"CZK","23":"CZK","manufacturer":"KIA","24":"KIA","model":"CEED (ED)","25":"CEED (ED)","submodel":"ACTIVE","26":"ACTIVE","orgName":"Global Expert","27":"Global Expert","textL":"BLATN\u00cdK P PLAKOV\u00c1N\u00cd NOV\u00ddCH D\u00cdL\u016e,DVE\u0158E P PLAK POVRCHU,P\u0158-N\u00c1RAZN\u00cdKLAKOV\u00c1N\u00cd NOV\u00ddCH D\u00cdL\u016e","28":"BLATN\u00cdK P PLAKOV\u00c1N\u00cd NOV\u00ddCH D\u00cdL\u016e,DVE\u0158E P PLAK POVRCHU,P\u0158-N\u00c1RAZN\u00cdKLAKOV\u00c1N\u00cd NOV\u00ddCH D\u00cdL\u016e","textE":null,"29":null},{"vin":"U5YFF24128L064909","0":"U5YFF24128L064909","case_id":"1468328","1":"1468328","claimnumber":"5M47465","2":"5M47465","platenumber":"5M47465","3":"5M47465","axrmrs_id":"2037572","4":"2037572","insurer_memberid":"","5":"","country":"CZ","6":"CZ","date_created":"2014-02-13 00:00:00","7":"2014-02-13 00:00:00","totalloss":"","8":"","lastcalc_manufacturer_code":"28","9":"28","lastcalc_model_code":"25","10":"25","lastcalc_submodel_code":"07","11":"07","audavin_triggered":"","12":"","accident_date":"0000-00-00 00:00:00","13":"0000-00-00 00:00:00","registration_date":"0000-00-00 00:00:00","14":"0000-00-00 00:00:00","manufacturing_year":"2008","15":"2008","spareparts":"25319.55","16":"25319.55","totalcosts":"41529.62","17":"41529.62","laborhours":"7.7","18":"7.7","laborcosts":"3850","19":"3850","calculationdate":"2014-02-23 23:02:00","20":"2014-02-23 23:02:00","paintlabor":"5995","21":"5995","paintmaterial":"6042.07","22":"6042.07","currency":"CZK","23":"CZK","manufacturer":"KIA","24":"KIA","model":"CEED (ED)","25":"CEED (ED)","submodel":"ACTIVE","26":"ACTIVE","orgName":"0","27":"0","textL":"BLAT","textE":null,"29":null}]
How I try it:
foreach ( $array ['result'] ['claim'] as $claim )
{
$data = array (
"claimnumber" =>$claim['@attributes']['id'],
"date_created" =>$claim['country'],
"country" =>$claim['creation'],
"currency" =>$claim ['specific']['currency'],
"insurer_memberid" =>$claim['insurance']['id'],
"laborcosts" =>$claim ['specific']['partsCost'],
"model" =>$claim ['specific']['model_name'],
"orgName" =>$claim['insurance']['name'],
"paintLabor" =>$claim['specific']['paintmaterial'],
"totalcosts" =>$claim ['assessment']['damage-value']
);
$result = array();
$result[] = $data;
$result[] = array_push($result, $this->convertToJson($result));
}
echo $result;
But this return just string "Array", is there some nice way how to create API which display array of objects?
Thanks for any advise :)