gpt4 book ai didi

javascript - JavaScript 中的.text 冲突

转载 作者:行者123 更新时间:2023-11-28 11:34:54 25 4
gpt4 key购买 nike

我有一个通过 JSON 生成的对象:

{
"notification": [
{
"mode": "MOBILE_PUSH",
"notificationRead": 0,
"actionTaken": 0,
"requestJson": {
"text": "Thisisanannouncement",
"image": "image_url",
"NOTIFICATION_ACTION_LINK": "action_link"
},
"externalReferenceId": "ref1",
"notificationId": 0,
"notificationDetailId": 1,
"notificationStatus": null
}
]
}

在这里,当我尝试访问诸如 notification.requestJson.text 之类的文本时,但我未定义。如果我将文本更改为其他内容,它工作正常。如何在不将文本更改为其他内容的情况下使其工作?

最佳答案

试试这个

data = {
"notification": [
{
"mode": "MOBILE_PUSH",
"notificationRead": 0,
"actionTaken": 0,
"requestJson": {
"text": "Thisisanannouncement",
"image": "image_url",
"NOTIFICATION_ACTION_LINK": "action_link"
},
"externalReferenceId": "ref1",
"notificationId": 0,
"notificationDetailId": 1,
"notificationStatus": null
}
]
}
console.log(data.notification[0].requestJson.text);

DEMO

关于javascript - JavaScript 中的.text 冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24750864/

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