I am working on hotels API, which needs to send data in JSON form,
But my JSON form is wrong and the API is not working.
My code is:-
$json = json_encode([
'RoomGuests' => [ json_encode(["NoOfAdults"=> 1,"NoOfChild"=> 0,"ChildAge"=> null])],
]);
And my output is :-
{
"RoomGuests": [
"{\"NoOfAdults\":1,\"NoOfChild\":0,\"ChildAge\":null}"
] }
And I want the result like this:-
{
"RoomGuests": [{
"NoOfAdults": 1,
"NoOfChild": 0,
"ChildAge": null
}], }
Please let me know how to solve this issue.