I have a php script on my website and this action is linked as a webhook to it. So once the data is submitted to the server, this is the response I send in json.
`{"payload":
{"google":
{"expectUserResponse":true,"
richResponse":
{"items":[{
"simpleResponse":{
"textToSpeech":"This feature is coming soon! Please wait until you receive a notification about its launch! You can verify if the details collected for your entry were right and inform the creator if they weren't. Here are the details."
}
},{"basicCard":{"title":"This is the entry I made","subtitle":"But I couldn't submit it","formattedText":"Item: Books \
Remarks: McDonalds \
Date: 2019-02-17T12:00:00+05:30 \
Amount: 2098 \
Category: Expense \
If the details above aren't right, please inform the creator."}}]}}}}'
But none of the get parsed. What I actually entered in php was a double space followed by single backslash and then n but for some reason php adds an extra backslash preventing it from escaping even when I used json encode json_unescaped_slashes. Here is the php code I used to create the json.
$response=new \stdClass();
$response->payload->google->expectUserResponse= true;
$items=new \stdClass();
$res->simpleResponse->textToSpeech="This feature is coming soon! Please wait until you receive a notification about its launch! You can verify if the details collected for your entry were right and inform the creator if they weren't. Here are the details.";
$items->basicCard->title="This is the entry I made";
$items->basicCard->subtitle="But I couldn't submit it";
$items->basicCard->formattedText="Item: ".$type."
Remarks: ".$item."
Date: ".$date."
Amount: ".$amount."
Category: ".$category."
If the details above aren't right, please inform the creator.";
$response->payload->google->richResponse->items[]=json_encode($res, JSON_UNESCAPED_SLASHES).",".json_encode($items, JSON_UNESCAPED_SLASHES);
$response2=str_replace('\"','"',json_encode($response, JSON_UNESCAPED_SLASHES));
$response2=str_replace('"{','{',$response2);
$response2=str_replace('}"','}',$response2);
echo $response2;
And this is the link to the screenshot of how it appears in the basicCard response https://photos.app.goo.gl/RzG5H3VgTJfrgfB59