我从服务器输出以下.我想从JSON输入获得"结果".
我的JSON输入是
{
"header":{
"type":"esummary",
"version":"0.3"
},
"result":{
"28885854":{
"uid":"28885854",
"pubdate":"2017 Sep 8",
"epubdate":"2017 Sep 8",
"source":"J Org Chem",
}
}
}
Run Code Online (Sandbox Code Playgroud)
我只喜欢javascript .Anyone帮助我做到这一点.
编辑:
我尝试了从服务器获取JSON的代码
var json = JSON.stringify(temp1);
console.log(json)
Run Code Online (Sandbox Code Playgroud)
我在控制台中的原始输出是这样的.
" {"header":{"type":"esummary","version":"0.3"},"result":{"28885854":{"uid":"28885854","pubdate":"2017年9月8日","epubdate":"2017年9月8日","来源":"J Org Chem","作者":[{"name":"Farmer LA","authtype":"作者","clusterid":" "},{"name":"Haidasz EA","authtype":"作者","clusterid":""},{"name":"Griesser M","authtype":"作者","clusterid" :""},{"name":"Pratt DA","authtype":"作者","clusterid":""}],"lastauthor":"Pratt DA","title":"Phenoxazine:A Privileged用于激进诱捕抗氧化剂的脚手架.","sorttitle":"吩恶嗪是激进诱捕抗氧化剂的特权支架","体积":"","问题":"","页数":"","郎":[ "eng"],"nlmuniqueid":"2985193R","issn":"0022-3263","essn":"1520-6904","pubtype":["Journal Article"],"recordstatus":"PubMed - 由发布者提供","pubstatus":"10","articleids":[{"idtype":"pubmed","idtypen":1,"value":"28885854"},{"idtype":" DOI " "idtypen":3 "值": "10.1021/acs.joc.7b02025"},{ "idtype": "RID", "idtypen":8中, "值": "28885854"},{" idtype ":" EID", "idtypen":8中, "值" :"28885854"}],"历史":[{"pubstatus":"entrez","date":"2017/09/09 06:00"},{"pubstatus":"pubmed","date": "2017/09/09 06:00"},{"pubstatus":"medline","date":"2017/09/09 06:00"}],"references":[],"attributes":[ "有摘要","pmcrefcount":"","fulljournalname":"有机化学杂志","elocationid":"doi:10.1021/acs.joc.7b02025","doctype":"引用"," srccontriblist ":[]," BOOKTITLE ":" " "中等": "", "版本": "", "publisherlocation": "", "PUBLISHERNAME": "", "srcdate": ""," reportnumber ":"", "availablefromurl": "", "locationlabel": "", "doccontriblist":[], "docdate": "", "BOOKNAME": "", "章节": "", "sortpubdate" :"2017/09/08 00:00","sortfirstauthor":"Farmer LA","vernaculartitle":""},"uids":["28885854"]}} "
我想你要找的就是.result.JSON.parse(...)如果你到目前为止只有JSON字符串,也许你也想要.
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);Run Code Online (Sandbox Code Playgroud)