简体   繁体   中英

Parse Json data OSM

I'm working to create an application, for get address without geocode by google. I found json data from OSM (openstreetmap), this is the link https://nominatim.openstreetmap.org/reverse?format=json&lat=-7.740601&lon=110.3333017&zoom=18&addressdetails=1

{  
   "place_id":"234438878",
   "licence":"Data © OpenStreetMap contributors, ODbL 1.0. https:\/\/osm.org\/copyright",
   "osm_type":"way",
   "osm_id":"585612977",
   "lat":"-7.74078232331096",
   "lon":"110.333420400495",
   "display_name":"Tlogoadi, Mlati, Sleman, Daerah Istimewa Yogyakarta, 55284, Indonesia",
   "address":{  
      "county":"Tlogoadi",
      "state_district":"Sleman",
      "state":"Daerah Istimewa Yogyakarta",
      "postcode":"55284",
      "country":"Indonesia",
      "country_code":"id"
   },
   "boundingbox":[  ]
}

my question is how to get display_name (single data) on above json format to Android ?

Try this

try 
{
    JSONObject jsonObject = new JSONObject(response);

    String displayName = jsonObject.getString("display_name")

    Log.e("Display Name",":"+ displayName);
}
catch (JSONException e) 
{
    e.printStackTrace();
}

OUTPUT:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM