gpt4 book ai didi

javascript - 使用字段从 json 字符串中获取值

转载 作者:行者123 更新时间:2023-11-30 10:19:17 25 4
gpt4 key购买 nike

我有一个 json 字符串。我想使用字段名称从该字符串中获取值。请帮我得到这个。这是我的 json 字符串格式。

[
{
"FLD_ID": 1,
"FLD_DATE": "17-02-2014 04:57:19 PM"
"FLD_USER_NAME": "DAFEDA",
"FLD_USER_EMAIL": "test@gmail.com",
"FLD_USER_PASS": "test"
}
]

最佳答案

我不太确定问题是什么,但是怎么样

// assuming str is your JSON string

var obj = JSON.parse(str); // parse the string into an object

var firstObj = obj[0]; // get the first (and only) object out of the array

var fld_id = firstObj.FLD_ID; // you can access properties by name like this

var fld_date = firstObj['FLD_DATE']; // or like this

关于javascript - 使用字段从 json 字符串中获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22162570/

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