2016-04-14 66 views
0

我读变JSON问题海槽REST API广东话读JSON变量槽REST API

问题:
的json
.....

“Featured_media”:11661,
“Comment_status”, “打开”
“Ping_status”, “打开”
“Geolocation_city”:[ “Oeiras的”],
“_links”:{
“Self”:[{
“Href”:“http:\/\/website.com \/wp-json \/wp \/v2 \/listing \/11660”
.....

我可以读取所有的变量,此代码

 $.getJSON('http://imaginocharme.com/wp-json/wp/v2/listings/11660', function (jd) { 

     $('#stage').html('<p> Nome: ' + jd.featured_media + '</p>'); 
     console.log(jd.featured_media); 
     $('#stage').append('<p>Descrição : ' + jd.comment_status + '</p>'); 
     console.log(jd.comment_status); 
     $('#stage').append('<p>Nome : ' + jd.ping_status + '</p>'); 
     console.log(jd.ping_status); 
     $('#stage').append('<p>Cidade : ' + jd.geolocation_city + '</p>'); 
     console.log(jd.geolocation_city); 
     $('#stage').append('<p>Links : ' + jd._links.self[0].href + '</p>'); 
     console.log(jd._links.self[0].href); 

      }); 


我的控制台日志少geolocation_city

11661 
index.html (29,29) 
open 
index.html (31,29) 
open 
index.html (33,29) 
undefined 
index.html (35,29) 
http://imaginocharme.com/wp-json/wp/v2/listings/11660 
index.html (37,29) 


我试过几种方法来读取变量geolocation_city和总给人不确定

谁能帮助?
有什么想法?

+0

你确定,大写/小写变量名不是问题吗? –

回答

0

jd.geolocation_city是一个数组,这就是为什么你没有显示它。试试这个:

jd.geolocation_city.toString() 
+0

没有工作:( –

+0

你能控制台登录jd.geolocation_city 的console.log(jd.geolocation_city); –

+0

回 的ReferenceError:在Object.InjectedScript._evaluateOn 1 :2:JD没有在定义 (:878:140) 在Object.InjectedScript._evaluateAndWrap(:811:34) 在Object.InjectedScript.evaluate(:667:21) 的ReferenceError:未定义JD ... –