gpt4 book ai didi

jquery - 如何解析 JSON 数据?

转载 作者:行者123 更新时间:2023-12-01 02:35:53 24 4
gpt4 key购买 nike

我如何解析下面的 JSON 数据作为我从服务器返回的响应数据,我想从这个 json 数据中提取值和标签,并且必须放在弹出窗口上..

例如:- 对于此数据"application_number":"20007524.8"

我想提取application_number作为Application Number,并对应于Application Number其值20007524.8

任何建议我该怎么做..

jsonp13082({"responseHeader":{"status":0,"Time":3,"params":{"json.wrf":"jsonp13082","wt":"json","q":"8377"}},"response":{"numFound":1,"start":0,"docs":[{"key":"83779616","number":"080","name":"Designated","name":"Non ","number":"27837","date":"2010-08-24T07:00:00Z","name":"Canada","name":"Application","title":"collision detection","date":"2008-03-03T08:00:00Z","id":"414","code":"CA","date":"2009-03-03T08:00:00Z","name":"Michael Henry","mgr_name":"abc","id":"79616","name":"oen","claims":"74","date":"2012-03-03T08:00:00Z","claims":"8","url":"","inventors":["D.","rshi","Pa"],"guid":["23","26","25"],"towners":["XYZ"],"inventors":["D","name2","name3"],"owners":["XYZ"]}]}})

最佳答案

有一个内置的parseJSON jQuery 中的函数。

编辑:使用示例:

// make a reference
var Obj = $.parseJSON('the json object');

alert(Obj.response.docs[0].c_application_number);

如何?

As you descend into the nodes, the name of the node goes on, so for example if you have a JSON object like this:

{
"parent": {
"sibling": "you found a sibling",
"child": {
"more_children": "hello"
}
}
}

使用这样的代码:

var json = $.parseJSON('{ "parent": { "sibling": "you found a sibling", "child": { "more_children": "hello" } } }');

// I want to get the sibling value
alert(json.parent.sibling);

// I want to get the children value
alert(json.parent.child.more_children);

Demo .

关于jquery - 如何解析 JSON 数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6378966/

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