【发布时间】:2020-12-26 16:42:31
【问题描述】:
您好,我正在学习 rails,在我的应用程序中,我从 res = @client.spots(params[:location][:lat], params[:location][:lng], :types => ['restaurant','food'], :radius => 500)
在我的 res 对象中,我得到了这些值
{
"json_result_object": {
"business_status": "OPERATIONAL",
"geometry": {
"location": {
"lat": 31.4734563,
"lng": 74.2794873
},
},
"icon": "https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
"name": "CP Five Star",
"opening_hours": {
"open_now": true
}
}
],
"place_id": "ChIJjfE-TdoDGTkRMom8KQfI9Uc",
"plus_code": {
"compound_code": "F7FH+9Q Lahore, Pakistan",
"global_code": "8J3PF7FH+9Q"
},
},
"reference": "ChIJjfE-TdoDGTkRMom8KQfI9Uc",
"place_id": "ChIJjfE-TdoDGTkRMom8KQfI9Uc",
"vicinity": "Bilal Arcade, Abdul Haque Road, Block G Block G Phase 1 Johar Town, Lahore",
"lat": 31.4734563,
"lng": 74.2794873,
"viewport": {
"northeast": {
"lat": 31.4748154802915,
"lng": 74.28081473029151
},
"southwest": {
"lat": 31.4721175197085,
"lng": 74.2781167697085
}
},
"name": "CP Five Star",
"icon": "https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
"types": [
"restaurant",
"food",
"point_of_interest",
"establishment
}
现在我只想返回一个 JSON 数组,其中仅包含以下值 place_id 、 name 、 lat 液化气,图标
& 抱歉,我使用图片只是为了在终端 image 中显示我的实际回复
【问题讨论】:
-
你的 json 不正确。你需要关注这个stackoverflow.com/a/7964378/297087
-
我从 json 编辑器获取这个
-
@Salil 我用终端的实际图像更新了我的问题,请看一下
标签: ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-6