1
我需要以编程方式构建以下JSON。但是,需要一种优雅的方式将Java对象转换为JSON。所以,我可以避免字符串生成器来构建下面的JSON。以编程方式在java中构建JSON
我意识到,有时候,我对在构建JSON的特定关键的参数数组。 请分享解决该问题的通用方法。
请分享一些想法了这一点。
{
"tropo": [
{
"ask": {
"attempts": 3,
"say": [
{
"value": "Hi.",
"event": "timeout"
},
{
"value": "Hello",
"event": "nomatch:1"
},
{
"value": "Hello2",
"event": "nomatch:2"
},
{
"value": "Satheesh",
"voice": "veronica"
}
],
"choices": {
"value": "Yes(1,Yes),No(2,No)",
"mode": "ANY"
},
"voice": "veronica",
"recognizer": "en-us",
"timeout": 8,
"name": "year",
"minConfidence": 39,
"required": true
}
},
{
"on": {
"next": "https://test.app.com/WAP2/",
"event": "continue"
}
},
{
"on": {
"next": "https://test.app.com/WAP2/",
"event": "incomplete"
}
},
{
"on": {
"next": "",
"event": "hangup"
}
}
]
}
你可以使用GSON库。 – Pratik