gpt4 book ai didi

javascript - 如何访问放置在 javascript 对象中的对象的属性?

转载 作者:行者123 更新时间:2023-11-30 10:01:44 26 4
gpt4 key购买 nike

我有一个 php 文件,可以将对象的 json 字符串发送到我的 javascript 文件。我在访问此 javascript 对象中包含的对象的属性时遇到问题。

我的 php 文件:

 for($i=0; $i<$hitcount; $i++){
if($i == $hitcount-1){
// IF HITCOUNT IS LESS THAN 25 RESULTS
echo json_encode($articleArray);
exit();
}else if($i == 25){
// THERE IS ONLY A MAX OF 25 RESULTS PER REQUEST
echo json_encode($articleArray);
exit();
}else{
$page = $xml -> request -> page ; //always page 1

$title = $xml ->resultList -> result[$i] -> title;
if($title == false){
$title = '';
}

$pmid = $xml ->resultList -> result[$i] -> pmid;
if($pmid == false){
$pmid = '';
}

$authorString = $xml ->resultList -> result[$i] -> authorString;
if($authorString == false){
$authorString ='';
}
$journalTitle = $xml ->resultList -> result[$i] -> journalTitle ;
if($journalTitle ==false){
$journalTitle = '';
}
$pubYear = $xml ->resultList -> result[$i] -> pubYear;
if($pubYear == false){
$pubYear = '';
}
$journalVolume = $xml ->resultList -> result[$i] -> journalVolume;
if($journalVolume == false){
$journalVolume = '';
}
$issue = $xml ->resultList -> result[v] -> issue;
if($issue == false){
$issue = '';
}
$pageInfo = $xml ->resultList -> result[$i] -> pageInfo;
if($pageInfo == false){
$pageInfo = '';
}


$articleArray[] = array(
'hitCount' => $hitcount,
'page' => $page,
'pmid' => $pmid,
'title' => $title,
'authors' => $authorString,
'journalTitle' => $journalTitle,
'pubYear' => $pubYear,
'journalVolume' => $journalVolume,
'issue' => $issue,
'pageInfo' => $pageInfo
);
}
}

我的 javascript 文件:

 // Retrieve json string
var json_obj = JSON.parse(xmlhttp.responseText);

我尝试了以下方法来访问存储在 javascript 对象中的对象的属性:

 json_obj[0].title // to access the title of the first object

这只是返回:

 [object Object]

xmlhttp.responseText:

 [{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"25745995"},"title":{"0":"Hypoxia upregulates Rab11-family interacting protein 4 through HIF-1\u03b1 to promote the metastasis of hepatocellular carcinoma."},"authors":{"0":"Hu F, Deng X, Yang X, Jin H, Gu D, Lv X, Wang C, Zhang Y, Huo X, Shen Q, Luo Q, Zhao F, Ge T, Zhao F, Chu W, Shu H, Yao M, Fan J, Qin W."},"journalTitle":{"0":"Oncogene"},"pubYear":{"0":"2015"},"journalVolume":"","issue":"","pageInfo":""},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"25800835"},"title":{"0":"Kinetic activation of Rab8 guanine nucleotide exchange factor Rabin8 by Rab11."},"authors":{"0":"Feng S, Wu B, Per\u00e4nen J, Guo W."},"journalTitle":{"0":"Methods Mol Biol"},"pubYear":{"0":"2015"},"journalVolume":{"0":"1298"},"issue":"","pageInfo":{"0":"99-106"}},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"26032412"},"title":{"0":"Structure-Function Analyses of the Interactions Between Rab11 and Rab14 Small GTPases with their Shared Effector Rab Coupling Protein (RCP)."},"authors":{"0":"Lall P, Lindsay A, Hanscom S, Kecman T, Taglauer ES, McVeigh UM, Franklin E, McCaffrey MW, Khan AR."},"journalTitle":{"0":"J Biol Chem"},"pubYear":{"0":"2015"},"journalVolume":"","issue":"","pageInfo":""},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"25815277"},"title":{"0":"Rab11 in disease progression."},"authors":{"0":"Bhuin T, Roy JK."},"journalTitle":{"0":"Int J Mol Cell Med"},"pubYear":{"0":"2015"},"journalVolume":{"0":"4"},"issue":"","pageInfo":{"0":"1-8"}},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"25800843"},"title":{"0":"In vitro and in vivo characterization of the Rab11-GAP activity of Drosophila Evi5."},"authors":{"0":"Laflamme C, Emery G."},"journalTitle":{"0":"Methods Mol Biol"},"pubYear":{"0":"2015"},"journalVolume":{"0":"1298"},"issue":"","pageInfo":{"0":"187-194"}},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"24917558"},"title":{"0":"Vasodilator-stimulated phosphoprotein promotes activation of hepatic stellate cells by regulating Rab11-dependent plasma membrane targeting of transforming growth factor beta receptors."},"authors":{"0":"Tu K, Li J, Verma VK, Liu C, Billadeau DD, Lamprecht G, Xiang X, Guo L, Dhanasekaran R, Roberts LR, Shah VH, Kang N."},"journalTitle":{"0":"Hepatology"},"pubYear":{"0":"2015"},"journalVolume":{"0":"61"},"issue":"","pageInfo":{"0":"361-374"}},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"25480917"},"title":{"0":"Vangl2 cooperates with Rab11 and Myosin V to regulate apical constriction during vertebrate gastrulation."},"authors":{"0":"Ossipova O, Chuykin I, Chu CW, Sokol SY."},"journalTitle":{"0":"Development"},"pubYear":{"0":"2015"},"journalVolume":{"0":"142"},"issue":"","pageInfo":{"0":"99-107"}},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"25831508"},"title":{"0":"TRAPPII regulates exocytic Golgi exit by mediating nucleotide exchange on the Ypt31 ortholog RabERAB11."},"authors":{"0":"Pinar M, Arst HN Jr, Pantazopoulou A, Tagua VG, de los R\u00edos V, Rodr\u00edguez-Salarichs J, D\u00edaz JF, Pe\u00f1alva MA."},"journalTitle":{"0":"Proc Natl Acad Sci U S A"},"pubYear":{"0":"2015"},"journalVolume":{"0":"112"},"issue":"","pageInfo":{"0":"4346-4351"}},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"25305083"},"title":{"0":"Rab11 modulates \u03b1-synuclein-mediated defects in synaptic transmission and behaviour."},"authors":{"0":"Breda C, Nugent ML, Estranero JG, Kyriacou CP, Outeiro TF, Steinert JR, Giorgini F."},"journalTitle":{"0":"Hum Mol Genet"},"pubYear":{"0":"2015"},"journalVolume":{"0":"24"},"issue":"","pageInfo":{"0":"1077-1091"}},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"25862161"},"title":{"0":"A novel role of Rab11 in trafficking GPI-anchored trans-sialidase to the plasma membrane of Trypanosoma cruzi."},"authors":{"0":"Niyogi S, Docampo R."},"journalTitle":{"0":"Small GTPases"},"pubYear":{"0":"2015"},"journalVolume":{"0":"6"},"issue":"","pageInfo":{"0":"8-10"}},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"25673879"},"title":{"0":"The Arf and Rab11 effector FIP3 acts synergistically with ASAP1 to direct Rabin8 in ciliary receptor targeting."},"authors":{"0":"Wang J, Deretic D."},"journalTitle":{"0":"J Cell Sci"},"pubYear":{"0":"2015"},"journalVolume":{"0":"128"},"issue":"","pageInfo":{"0":"1375-1385"}},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"25972173"},"title":{"0":"Synaptic Function of Rab11Fip5: Selective Requirement for Hippocampal Long-Term Depression."},"authors":{"0":"Bacaj T, Ahmad M, Jurado S, Malenka RC, S\u00fcdhof TC."},"journalTitle":{"0":"J Neurosci"},"pubYear":{"0":"2015"},"journalVolume":{"0":"35"},"issue":"","pageInfo":{"0":"7460-7474"}},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"25632160"},"title":{"0":"Myosin Va mediates BDNF-induced postendocytic recycling of full-length TrkB and its translocation into dendritic spines."},"authors":{"0":"Sui WH, Huang SH, Wang J, Chen Q, Liu T, Chen ZY."},"journalTitle":{"0":"J Cell Sci"},"pubYear":{"0":"2015"},"journalVolume":{"0":"128"},"issue":"","pageInfo":{"0":"1108-1122"}},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"25686250"},"title":{"0":"Early steps in primary cilium assembly require EHD1\/EHD3-dependent ciliary vesicle formation."},"authors":{"0":"Lu Q, Insinna C, Ott C, Stauffer J, Pintado PA, Rahajeng J, Baxa U, Walia V, Cuenca A, Hwang YS, Daar IO, Lopes S, Lippincott-Schwartz J, Jackson PK, Caplan S, Westlake CJ."},"journalTitle":{"0":"Nat Cell Biol"},"pubYear":{"0":"2015"},"journalVolume":{"0":"17"},"issue":"","pageInfo":{"0":"228-240"}},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"25904794"},"title":{"0":"Protein Interacting with C-Kinase 1 Deficiency Impairs Glutathione Synthesis and Increases Oxidative Stress via Reduction of Surface Excitatory Amino Acid Carrier 1."},"authors":{"0":"Wang YN, Zhou L, Li YH, Wang Z, Li YC, Zhang YW, Wang Y, Liu G, Shen Y."},"journalTitle":{"0":"J Neurosci"},"pubYear":{"0":"2015"},"journalVolume":{"0":"35"},"issue":"","pageInfo":{"0":"6429-6443"}},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"26041286"},"title":{"0":"Intracellular Transport of Vaccinia Virus in HeLa Cells Requires WASH-VPEF\/FAM21-Retromer Complexes and Recycling molecules Rab11 and Rab22."},"authors":{"0":"Hsiao JC, Chu LW, Lo YT, Lee SP, Chen TJ, Huang CY, Ping YH, Chang W."},"journalTitle":{"0":"J Virol"},"pubYear":{"0":"2015"},"journalVolume":"","issue":"","pageInfo":""},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"25704914"},"title":{"0":"Mechanisms regulating cell membrane localization of the chemokine receptor CXCR4 in human hepatocarcinoma cells."},"authors":{"0":"Cepeda EB, Dediulia T, Fernando J, Bertran E, Egea G, Navarro E, Fabregat I."},"journalTitle":{"0":"Biochim Biophys Acta"},"pubYear":{"0":"2015"},"journalVolume":{"0":"1853"},"issue":"","pageInfo":{"0":"1205-1218"}},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"26021297"},"title":{"0":"The small GTPase Rab29 is a common regulator of immune synapse assembly and ciliogenesis."},"authors":{"0":"Onnis A, Finetti F, Patrussi L, Gottardo M, Cassioli C, Span\u00f2 S, Baldari CT."},"journalTitle":{"0":"Cell Death Differ"},"pubYear":{"0":"2015"},"journalVolume":"","issue":"","pageInfo":""},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"26004511"},"title":{"0":"Slitrk5 Mediates BDNF-Dependent TrkB Receptor Trafficking and Signaling."},"authors":{"0":"Song M, Giza J, Proenca CC, Jing D, Elliott M, Dincheva I, Shmelkov SV, Kim J, Schreiner R, Huang SH, Castr\u00e9n E, Prekeris R, Hempstead BL, Chao MV, Dictenberg JB, Rafii S, Chen ZY, Rodriguez-Boulan E, Lee FS."},"journalTitle":{"0":"Dev Cell"},"pubYear":{"0":"2015"},"journalVolume":{"0":"33"},"issue":"","pageInfo":{"0":"690-702"}},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"25753037"},"title":{"0":"LTP-triggered cholesterol redistribution activates Cdc42 and drives AMPA receptor synaptic delivery."},"authors":{"0":"Brachet A, Norwood S, Brouwers JF, Palomer E, Helms JB, Dotti CG, Esteban JA."},"journalTitle":{"0":"J Cell Biol"},"pubYear":{"0":"2015"},"journalVolume":{"0":"208"},"issue":"","pageInfo":{"0":"791-806"}},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"26110570"},"title":{"0":"Predominant Rab-GTPase amplicons contributing to oral squamous cell carcinoma progression to metastasis."},"authors":{"0":"da Silva SD, Marchi FA, Xu B, Bijian K, Alobaid F, Mlynarek A, Rogatto SR, Hier M, Kowalski LP, Alaoui-Jamali MA."},"journalTitle":{"0":"Oncotarget"},"pubYear":{"0":"2015"},"journalVolume":"","issue":"","pageInfo":""},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"26067165"},"title":{"0":"Site-Specific Phosphorylation of VEGFR2 Is Mediated by Receptor Trafficking: Insights from a Computational Model."},"authors":{"0":"Clegg LW, Mac Gabhann F."},"journalTitle":{"0":"PLoS Comput Biol"},"pubYear":{"0":"2015"},"journalVolume":{"0":"11"},"issue":"","pageInfo":{"0":"e1004158"}},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"25941134"},"title":{"0":"Mechanisms of apical-basal axis orientation and epithelial lumen positioning."},"authors":{"0":"Overeem AW, Bryant DM, van IJzendoorn SC."},"journalTitle":{"0":"Trends Cell Biol"},"pubYear":{"0":"2015"},"journalVolume":"","issue":"","pageInfo":""},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"25394938"},"title":{"0":"The fungal pathogen Cryptococcus neoformans manipulates macrophage phagosome maturation."},"authors":{"0":"Smith LM, Dixon EF, May RC."},"journalTitle":{"0":"Cell Microbiol"},"pubYear":{"0":"2015"},"journalVolume":{"0":"17"},"issue":"","pageInfo":{"0":"702-713"}},{"hitCount":{"0":"3347"},"page":{"0":"1"},"pmid":{"0":"25800842"},"title":{"0":"3D time-lapse analysis of Rab11\/FIP5 complex: spatiotemporal dynamics during apical lumen formation."},"authors":{"0":"Mangan A, Prekeris R."},"journalTitle":{"0":"Methods Mol Biol"},"pubYear":{"0":"2015"},"journalVolume":{"0":"1298"},"issue":"","pageInfo":{"0":"181-186"}}]

最佳答案

因为标题实际上是一个Object

"title":{
"0":"Hypoxia upregulates Rab11-family interacting protein 4 through HIF-1\u03b1 to promote the metastasis of hepatocellular carcinoma."
}

如果你不能改变输出尝试这样访问:

json_obj[0].title["0"];

但如果标题来自您准备使用的 php 会更好。在这种情况下,我看不出有任何理由返回数组。

关于javascript - 如何访问放置在 javascript 对象中的对象的属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31279919/

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