【发布时间】:2019-12-30 13:33:43
【问题描述】:
我想提取 queryResult 的子值,即。 “你好。我是聊天机器人所以我们开始吧?”从 JSON 使用颤振
最终responseJson = json.decode(response.body);
print("DATA \n ${responseJson['queryResult']}");
JSON 数据 ===>
{
"responseId":"123456789",
"queryResult":{
"queryText":"Hello",
"action":"input.welcome",
"parameters":{
},
"allRequiredParamsPresent":true,
"fulfillmentText":"Greetings! How can I assist?",
"fulfillmentMessages":[
{
"text":{
"text":[
"Hello there. I am chat bot So shall we get started?"
]
}
},
{
"quickReplies":{
"quickReplies":[
"Yes",
"No"
]
}
}
],
"outputContexts":[
{
"name":"xyz",
"lifespanCount":5
}
],
"intent":{
"name":"xyz",
"displayName":"Default Welcome Intent"
},
"intentDetectionConfidence":1,
"diagnosticInfo":{
"webhook_latency_ms":5
},
"languageCode":"en"
},
"webhookStatus":{
"message":"Webhook execution successful"
}
}
我无法读取 queryResult 的子数据使用
final responseJson = json.decode(response.body);
print("DATA \n ${responseJson['queryResult']}");
【问题讨论】:
-
您需要使用模式序列化您的 json 数据。这是链接flutter.dev/docs/development/data-and-backend/json
标签: android json android-studio flutter dart