I don\'t work with php much and I\'m a little fuzzy on object creation. I need to make a webservice request sending json and I think I have that part covered. Before I can
We can also construct nested array and then do a json_encode to construct nested JSON.
For e.g:
{"User":
{"username":"test",
"address":"Posted value fro address field",
"location":{
"id":12345
}
}
}
Above output we can achieve by writing below php code:
<?php
$obj = array(
'username'=>$lv_username,
'address'=>$lv_address,
'location'=>array('id'=>$lv_locationId)
);
$data = '{"User":'. json_encode($obj) .'}';
echo $data;
?>
Hope it helps.