Я хочу добавить URL-адрес вместе с выводом текста в виде json с моей веб-страницы php, и для этого я использовал функцию json_encode()
в php, а ниже приведен массив php, который будет преобразован в json:
$output= array (
'payload' =>
array (
'google' =>
array (
'expectUserResponse' => true,
'richResponse' =>
array (
'items' =>
array (
0 =>
array (
'simpleResponse' =>
array (
'textToSpeech' => '<speak>some text... <audio src=\"https://example.com\"></audio></speak>',
'displayText' => 'some text...',
),
),
),
'suggestions' =>
array (
0 =>
array (
'title' => 'cancel',
),
),
),
),
),
);
echo json_encode($output);
и этот php-код выдает следующий вывод json:
{
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "<speak>some text... <audio src=\\\"https://example.com\\\"></audio></speak>",
"displayText": "some text..."
}
}
],
"suggestions": [
{
"title": "cancel"
}
]
}
}
}
}
Но мне нужен следующий вывод json:
{
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "<speak>some text... <audio src=\"https://example.com\"></audio></speak>",
"displayText": "some text..."
}
}
],
"suggestions": [
{
"title": "cancel"
}
]
}
}
}
}
Я не понимал, как бросить URL в JSON согласно моему требованию.