Adding newline and spacing in watson conversation output (JSON)

假装没事ソ 提交于 2019-12-11 06:05:07

问题


I want the watson conversation to give an output like:


I can solve the problems for the following products.

1 Air Conditioner

2 Refrigerator

3 Washing Machine


I am trying the following in JSON. But I am getting all the text cramped together.


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


I have also tried \n and \t which is also unsuccessful. Is there any way to get the text properly spaced in the JSON text tag. (I used the conversation tool to everything)


回答1:


I found the answer!!

add

"br" tags in the simple format of JSON. It is not reflected on the test chat, the change is only reflected on deploying it in an app




回答2:


Try this:

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

As per documentation:

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.

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



来源:https://stackoverflow.com/questions/40023329/adding-newline-and-spacing-in-watson-conversation-output-json

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!