gpt4 book ai didi

javascript - 访问 JSON 对象中的字段

转载 作者:行者123 更新时间:2023-12-03 12:21:11 25 4
gpt4 key购买 nike

在我的 JSON 对象中,我尝试访问“pos”中的“name”字段

我尝试过 obj.tokens.pos.parent; obj[0].pos.parent;

如何访问该对象的父字段?

该对象看起来像

[
{
"tokens": [
{
"text": "call",
"normalised": "call",
"end": true,
"start": true,
"pos": {
"name": "infinitive verb",
"example": "eat",
"parent": "verb",
"tense": "present",
"tag": "VBP"
},
"pos_reason": "lexicon",
"analysis": {
"word": "call",
"next": null,
"last": null,
"form": "infinitive",
"tense": "present",
"which": {
"name": "infinitive verb",
"example": "eat",
"parent": "verb",
"tense": "present",
"tag": "VBP"
},
"negative": false
}
}
]
}
]

最佳答案

这里的结果是数组格式,因此您需要访问像 obj[0] 这样的数组元素

obj[0].tokens[0].pos.name

关于javascript - 访问 JSON 对象中的字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24443760/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com