Json parse

padvou

Active Member
Licensed User
Longtime User
Could someone please help me with reading this json text:
B4X:
{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "1600",
               "short_name" : "1600",
               "types" : [ "street_number" ]
            },
            {
               "long_name" : "Amphitheatre Parkway",
               "short_name" : "Amphitheatre Pkwy",
               "types" : [ "route" ]
            },
            {
               "long_name" : "Mountain View",
               "short_name" : "Mountain View",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Santa Clara",
               "short_name" : "Santa Clara",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Καλιφόρνια",
               "short_name" : "CA",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Ηνωμένες Πολιτείες",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "94043",
               "short_name" : "94043",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "1600 Amphitheatre Parkway, Mountain View, Καλιφόρνια 94043, Ηνωμένες Πολιτείες Αμερικής",
         "geometry" : {
            "location" : {
               "lat" : 37.42285760,
               "lng" : -122.08506470
            },
            "location_type" : "ROOFTOP",
            "viewport" : {
               "northeast" : {
                  "lat" : 37.42420658029150,
                  "lng" : -122.0837157197085
               },
               "southwest" : {
                  "lat" : 37.42150861970850,
                  "lng" : -122.0864136802915
               }
            }
         },
         "types" : [ "street_address" ]
      }
   ],
   "status" : "OK"
}
 

padvou

Active Member
Licensed User
Longtime User
B4X:
 Dim JSON As JSONParser
    Dim Map1 As Map
   Map1.Initialize
    JSON.Initialize(gotstring)
    Map1 = JSON.NextObject
    
    Dim m As Map
    Dim resultslist As List
    m.Initialize
   resultslist.Initialize
    resultslist = Map1.Get("results")
   ' Msgbox(featuresList.Get(0),"")
    For i = 0 To resultslist.Size - 1
        m = resultslist.Get(i)
        m = m.Get("geometry")
       m = m.Get("location")
       wlat= m.Get("lat")
      wlng= m.Get("lng")
    Next
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
Hi padvou,
Please see this
 
Upvote 0
Top