我的服务器输出如下。我想从JSON输入中获取"结果" 。
我的JSON输入是
{
"header":{
"type":"esummary",
"version":"0.3"
},
"result":{
"28885854":{
"uid":"28885854",
"pubdate":"2017 Sep 8",
"epubdate":"2017 Sep 8",
"source":"J Org Chem",
}
}
}
我只选择 javascript 。有人帮我这样做。
编辑:
我尝试使用代码从服务器获取JSON
var json = JSON.stringify(temp1);
console.log(json)
我在控制台中的原始输出是这样的。
" 的 {"头" {"类型":" esummary""版本":" 0.3" },"导致" {" 28885854" {" UID":" 28885854"" pubdate的":& #34; 2017年9月8日"," epubdate":" 2017年9月8日","来源":" J Org Chem", "作者":[{"姓名":" Farmer LA"," authtype":"作者",&# 34; clusterid":""},{" name":" Haidasz EA"," authtype":"作者"," clusterid":""},{"名称":" Griesser M"," authtype&# 34;:"作者"," clusterid":""},{"名称":" Pratt DA" "的authType":"作者""群ID":""}]," lastauthor":&# 34; Pratt DA"," title":"吩恶嗪:一种特殊的支架,用于治疗激进的抗氧化剂。"," sorttitle":"吩恶嗪是激进诱捕抗氧化剂的特权支架","体积":"","问题":&#3 4;""页面":"""朗":["主机&#34]," nlmuniqueid& #34;:" 2985193R"" ISSN":" 0022-3263"" ESSN":" 1520-6904&# 34;," pubtype":["期刊文章"]," recordstatus":" PubMed - 由出版商提供",&#34 ; pubstatus":" 10"" articleids":[{" idtype":"搜索PubMed"" idtypen&# 34;:1,"值":" 28885854"},{" idtype":" DOI"" idtypen&#34 ; 3"值":" 10.1021 / acs.joc.7b02025"},{" idtype":"去掉"&# 34; idtypen":8,"值":" 28885854"},{" idtype":" EID"&#34 ; idtypen":8,"值":" 28885854"}],"历史":[{" pubstatus":&# 34; entrez"," date":" 2017/09/09 06:00"},{" pubstatus":" pubmed&#34 ;," date":" 2017/09/09 06:00"},{" pubstatus":" medline",&#34 ;日期":" 2017/09/09 06:00"}],"参考" :[],"属性":["有抽象"]," pmcrefcount":""," fulljournalname&#34 ;:"有机化学杂志"," elocationid":" doi:10.1021 / acs.joc.7b02025"," doctype": "引文"" srccontriblist":[]," BOOKTITLE":"""介质":&# 34;""版":""" publisherlocation":""" PUBLISHERNAME&#34 ;:""" srcdate":""" reportnumber":""&#34 ; availablefromurl":""" locationlabel":""" doccontriblist":[]," docdate& #34;:""" BOOKNAME":"""章":"",& #34; sortpubdate":" 2017/09/08 00:00"," sortfirstauthor":" Farmer LA"," vernaculartitle&#34 ;:""}"的uid":[" 28885854"]}} "
答案 0 :(得分:5)
我认为你所寻找的只是.result
。如果到目前为止只有JSON字符串,也许你也想要JSON.parse(...)
。
var obj = {
"header": {
"type": "esummary",
"version": "0.3"
},
"result": {
"28885854": {
"uid": "28885854",
"pubdate": "2017 Sep 8",
"epubdate": "2017 Sep 8",
"source": "J Org Chem",
}
}
};
console.log(obj.result);
// To address edits above and comments below:
console.log(obj.result["28885854"].source);