我正在尝试获取opening_hours的值。我可以看到日志中的值,但是当我尝试从json获取它时,有一个json异常说“open_hours没有值” 这是json
"results" : [
{
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
"id" : "4b20e94074c34e7912f3b53b1fc9409730e57017",
"name" : "Chicken & Pizza Hot Service",
"opening_hours" : {
"open_now" : true,
"weekday_text" : []
},
"place_id" : "ChIJ_-_K26Kv2EcR8gAnIBZax5o",
"rating" : 2.4,
"scope" : "GOOGLE",
"types" : [
"meal_takeaway",
"restaurant",
"food",
"point_of_interest",
"establishment"
],
"vicinity" : "32 Station Road, Belvedere"
},
{
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
"id" : "4b17d2a5a90d4daaa8c8a3a283e2036fec21be08",
"name" : "McDonald's",
"opening_hours" : {
"open_now" : true,
"weekday_text" : []
},
"place_id" : "ChIJnbG7z56l2EcRzTTK1FgePRg",
"price_level" : 1,
"rating" : 3.7,
"scope" : "GOOGLE",
"types" : [ "restaurant", "food", "point_of_interest", "establishment" ],
"vicinity" : "3, Cook Road, Dagenham"
}
这是我的代码
var rootobject:JSONObject= JSONObject(response)
var objectarray:JSONArray=rootobject.getJSONArray("results")
for(i in 0..objectarray.length()-1){
var part:JSONObject=objectarray.getJSONObject(i)
var timepart:JSONObject=part.getJSONObject("opening_hours")