在 watson 对话输出中添加换行符和空格 (JSON)

Adding newline and spacing in watson conversation output (JSON)

我希望 watson 对话提供如下输出:


我可以解决以下产品的问题。

1台空调

2 台冰箱

3台洗衣机


我正在 JSON 中尝试以下操作。但是我把所有的文字都挤在一起了。


{ "output":{ "text": "I can solve the problems for the following products.\n\n1\tAir Conditioner\n2\tRefrigerator\n3\tWashing Machine" } }


我也试过\n和\t,也不成功。有什么方法可以让文本在 JSON text 标签中正确间隔。 (我什么都用对话工具)

我找到了答案!!

添加

"br" 标签的简单格式为 JSON。它不会反映在测试聊天中,更改只会反映在将其部署到应用程序中

试试这个:

{
    "output": {
        "text": ["I can solve the problems for the following products.",
            "1\tAir Conditioner", "2\tRefrigerator", "3\tWashing Machine"
        ]
    }
}

根据文档:

To specify more than one statement that you want to display on separate lines, define the output as a JSON array.

The first sentence is displayed on one line, and the second sentence is displayed as a new line below it.

来源:https://console.bluemix.net/docs/services/conversation/dialog-build.html#responses