【发布时间】:2019-12-10 12:52:18
【问题描述】:
我如何从下面的 json 中提取 text,因为它包含 \" 它给了我一个未定义的
{
"answers":[
{
"questions":[ ],
"answer":"{\"text\":\"I am Ellina. I can't believe you forgot my name\",\"speech\":\"I am Ellina. I can't believe you forgot my name\"}",
"score":100,
"id":106,
"source":"Editorial",
"metadata":[
],
"context":{
"isContextOnly":false,
"prompts":[
]
}
}
],
"debugInfo":null,
"activeLearningEnabled":false
}
我尝试使用 console.log(
Answer: ${JSON.stringify(res.data.answers[0].answer.text)});并且 控制台.log(Answer: ${res.data.answers[0].answer.text});
【问题讨论】:
-
如果
JSON.parse不解析 JSON,它就不是 JSON - 当你尝试像这样嵌套 JSON 时,它永远不会漂亮...answer的值是一个字符串,看起来像JSON
标签: javascript node.js json jsonparser