I have the following script that returns a json response.
$response["customer_creds"] =array(array('customer_names'=>$user['name'], 'customer_email' => $user['email'], 'customer_id' => $user['customer_id'], 'customer_type' => $user['customer_type'], 'rating' => $user['rating']));
The above script returns:
"customer_creds": [
{
"customer_names": "John Doe",
"customer_email": "[email protected]",
"customer_id": "123456",
"customer_type": "1",
"rating": "4"
}
],
Now I want my json to return the customer_type as an object.("customer_type": [1],
I have tried json decoding and encoding on the same script but nothing seems to work. Any workarounds on this? At a later stage I'll want to have my json to return multiple customer types. The final response should be something like this:
"customer_creds": [
{
"customer_names": "John Doe",
"customer_email": "[email protected]",
"customer_id": "123456",
"customer_type": [1,2,3],
"rating": "4"
}
],
Any suggestion would be highly appreciated. Thanks
customer_type'to be an array, then assign an array:'customer_type' => array(...). This has nothing to do with JSON.