从哈希数组返回特定​​值-JSON

问题描述

我正在学习Rails,在我的应用中,我从JSON格式中获取了值
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","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
    }
  },"types": [
    "restaurant","food","point_of_interest","establishment
  
}

现在我只想返回一个仅包含place_id,name,lat以下值的JSON数组 lng,图标

&抱歉,我使用的图像只是为了显示终端image上的实际响应

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)