gpt4 book ai didi

javascript - 如何从jsondata中获取key的值

转载 作者:太空宇宙 更新时间:2023-11-04 02:52:02 25 4
gpt4 key购买 nike

{
"Records": [{
"messageId": "20ea364e-3bc107b5c78c",
"receiptHandle": "AQEB6DhNloFS4R66c=",
"body": "1",
"attributes": {
"ApproximateReceiveCount": "1",
"SentTimestamp": "15393506",
"SenderId": "AROAJMTI6NE:errorLog",
"ApproximateFirstReceiveTimestamp": "15393511"
},
"messageAttributes": {},
"md5OfBody": "c4ca75849b",
"eventSource": "aws:sqs",
"eventSourceARN": "arn:aws:sqs:ap-suth-1:83362:escalateErrorStandardQueue",
"awsRegion": "ap-south-1"
}]

}

我想获取键“body”的值,预期输出应该是:1

最佳答案

var data={
"Records": [{
"messageId": "20ea364e-3bc107b5c78c",
"receiptHandle": "AQEB6DhNloFS4R66c=",
"body": "1",
"attributes": {
"ApproximateReceiveCount": "1",
"SentTimestamp": "15393506",
"SenderId": "AROAJMTI6NE:errorLog",
"ApproximateFirstReceiveTimestamp": "15393511"
},
"messageAttributes": {},
"md5OfBody": "c4ca75849b",
"eventSource": "aws:sqs",
"eventSourceARN": "arn:aws:sqs:ap-suth-1:83362:escalateErrorStandardQueue",
"awsRegion": "ap-south-1"
}]
};
console.log(data.Records[0].body);

您只需通过data.Records[0].body即可访问数据。

关于javascript - 如何从jsondata中获取key的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52819332/

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