As per application requirement, I am trying to develop two PHP which can communicate with each other via Json. I tried searching online but didn\'t found solution.
Can
Since you shouldn't use json_encode
if the data already is in json
format, change your code to something like:
$data = array('user' => array(
array('firstName' => 'Vignesh', 'lastName' => 'Prajapati'),
array('firstName' => 'Vaibhav', 'lastName' => 'Prajapati')
));
Of course you will need to add the other fields to the array as well.
Using json_encode()
on the above data will return:
{
"user" : [
{
"firstName" : "Vignesh",
"lastName" : "Prajapati"
},
{
"firstName" : "Vaibhav",
"lastName" : "Prajapati"
}
]
}