Spanish {SOLUCIONADO}como tomar este valor de google.

mvera

Active Member
Licensed User
Longtime User
hola estoy tratando de tomar este valor que saco de google

B4X:
{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "916",
               "short_name" : "916",
               "types" : [ "street_number" ]
            },
            {
               "long_name" : "Santo Domingo",
               "short_name" : "Santo Domingo",
               "types" : [ "route" ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "administrative_area_level_3", "political" ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Región Metropolitana",
               "short_name" : "Región Metropolitana",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Chile",
               "short_name" : "CL",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Santo Domingo 916, Santiago, Región Metropolitana, Chile",
         "geometry" : {
            "location" : {
               "lat" : -33.436248,
               "lng" : -70.65021899999999
            },
            "location_type" : "ROOFTOP",
            "viewport" : {
               "northeast" : {
                  "lat" : -33.4348990197085,
                  "lng" : -70.6488700197085
               },
               "southwest" : {
                  "lat" : -33.4375969802915,
                  "lng" : -70.6515679802915
               }
            }
         },
         "place_id" : "ChIJryKYQaPFYpYRjmNo8vl2i6Q",
         "types" : [ "street_address" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "PA262-Parada 2 / (M) Plaza De Armas",
               "short_name" : "PA262-Parada 2 / (M) Plaza De Armas",
               "types" : [
                  "bus_station",
                  "establishment",
                  "point_of_interest",
                  "transit_station"
               ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "administrative_area_level_3", "political" ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Región Metropolitana",
               "short_name" : "Región Metropolitana",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Chile",
               "short_name" : "CL",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "PA262-Parada 2 / (M) Plaza De Armas, Santiago, Región Metropolitana, Chile",
         "geometry" : {
            "location" : {
               "lat" : -33.4361383,
               "lng" : -70.65106059999999
            },
            "location_type" : "GEOMETRIC_CENTER",
            "viewport" : {
               "northeast" : {
                  "lat" : -33.4347893197085,
                  "lng" : -70.6497116197085
               },
               "southwest" : {
                  "lat" : -33.43748728029149,
                  "lng" : -70.6524095802915
               }
            }
         },
         "place_id" : "ChIJ5-rkWKPFYpYRpBfw9Uz4f7I",
         "types" : [
            "bus_station",
            "establishment",
            "point_of_interest",
            "transit_station"
         ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "administrative_area_level_3", "political" ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Región Metropolitana",
               "short_name" : "Región Metropolitana",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Chile",
               "short_name" : "CL",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Santiago, Región Metropolitana, Chile",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : -33.425617,
                  "lng" : -70.6251297
               },
               "southwest" : {
                  "lat" : -33.4811177,
                  "lng" : -70.7332574
               }
            },
            "location" : {
               "lat" : -33.4378305,
               "lng" : -70.6504492
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : -33.425617,
                  "lng" : -70.6251297
               },
               "southwest" : {
                  "lat" : -33.4811177,
                  "lng" : -70.7332574
               }
            }
         },
         "place_id" : "ChIJuzrymgbQYpYRl0jtCfRZnYc",
         "types" : [ "locality", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "colloquial_area", "locality", "political" ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Región Metropolitana",
               "short_name" : "Región Metropolitana",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Chile",
               "short_name" : "CL",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Santiago, Región Metropolitana, Chile",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : -33.2713874,
                  "lng" : -70.42678069999999
               },
               "southwest" : {
                  "lat" : -33.6741885,
                  "lng" : -70.8328819
               }
            },
            "location" : {
               "lat" : -33.4488897,
               "lng" : -70.66926549999999
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : -33.2713874,
                  "lng" : -70.42678069999999
               },
               "southwest" : {
                  "lat" : -33.6741885,
                  "lng" : -70.8328819
               }
            }
         },
         "place_id" : "ChIJL68lBEHFYpYRMQkPQDzVdYQ",
         "types" : [ "colloquial_area", "locality", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "administrative_area_level_3", "political" ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Región Metropolitana",
               "short_name" : "Región Metropolitana",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Chile",
               "short_name" : "CL",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Santiago, Región Metropolitana, Chile",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : -33.425617,
                  "lng" : -70.6251297
               },
               "southwest" : {
                  "lat" : -33.4785507,
                  "lng" : -70.6918738
               }
            },
            "location" : {
               "lat" : -33.45,
               "lng" : -70.66669999999999
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : -33.425617,
                  "lng" : -70.6251297
               },
               "southwest" : {
                  "lat" : -33.4785507,
                  "lng" : -70.6918738
               }
            }
         },
         "place_id" : "ChIJI8xkFgbFYpYRBYHTR-J6eXw",
         "types" : [ "administrative_area_level_3", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Región Metropolitana",
               "short_name" : "Región Metropolitana",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Chile",
               "short_name" : "CL",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Santiago, Región Metropolitana, Chile",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : -33.1025363,
                  "lng" : -70.17483899999999
               },
               "southwest" : {
                  "lat" : -33.62800259999999,
                  "lng" : -70.9577496
               }
            },
            "location" : {
               "lat" : -33.45,
               "lng" : -70.66669999999999
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : -33.1025363,
                  "lng" : -70.17483899999999
               },
               "southwest" : {
                  "lat" : -33.62800259999999,
                  "lng" : -70.9577496
               }
            }
         },
         "place_id" : "ChIJlVV_vxvJYpYRziXz-KE8chY",
         "types" : [ "administrative_area_level_2", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Región Metropolitana",
               "short_name" : "Región Metropolitana",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Chile",
               "short_name" : "CL",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Región Metropolitana, Chile",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : -32.919451,
                  "lng" : -69.7689943
               },
               "southwest" : {
                  "lat" : -34.2878148,
                  "lng" : -71.7088102
               }
            },
            "location" : {
               "lat" : -33.4375545,
               "lng" : -70.6504896
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : -32.919451,
                  "lng" : -69.7689943
               },
               "southwest" : {
                  "lat" : -34.2878148,
                  "lng" : -71.7088102
               }
            }
         },
         "place_id" : "ChIJUR74fWpvYpYR2oNLRG3CzWA",
         "types" : [ "administrative_area_level_1", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Chile",
               "short_name" : "CL",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Chile",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : -17.4983293,
                  "lng" : -66.3327
               },
               "southwest" : {
                  "lat" : -56.1455,
                  "lng" : -110.0281
               }
            },
            "location" : {
               "lat" : -35.675147,
               "lng" : -71.542969
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : -17.4983293,
                  "lng" : -66.3327
               },
               "southwest" : {
                  "lat" : -56.1455,
                  "lng" : -110.0281
               }
            }
         },
         "place_id" : "ChIJL68lBEHFYpYRHbkCERPhBQU",
         "types" : [ "country", "political" ]
      }
   ],
   "status" : "OK"
}

Lo intento de tomar asi desde b4a:
B4X:
Sub b_Click
    Dim miniruta As String
    miniruta="https://maps.googleapis.com/maps/api/geocode/json?latlng=-33.453454,-70.562686"

   
 
    geocoder_direccion.PostString(miniruta,"")
   
   
   
End Sub




'JOBDONE
Sub JobDone(Job As HttpJob)
Try



    Dim m As Map
    Dim respuesta,id,query,comentario,fecha,hora,iden_reporte,iden_reporte1,duplicado,tduplicado As String






    m.Initialize()

    Log("entramos....."&Job.Success)
    Log("mesaje "&Job.ErrorMessage)


    If Job.Success Then
        Dim res As String
        res = Job.GetString

        Log("Response from server: " & res)
        Dim parser As JSONParser







        parser.Initialize(res)

        Log("NOMBRE....."&Job.JobName)

        Select Job.JobName





            Case "geocoder"

               Log("entro")


                Dim tipo_i As List
                tipo_i= parser.NextArray 'returns a list with maps


                For i = 0 To tipo_i.Size - 1


                    Dim m As Map
                    m = tipo_i.Get(i)


                    respuesta= m.Get("results")
                    Log("xxx"&respuesta)
                   


                    m.Clear
                Next


        End Select
    Else






    End If
    Job.Release


Catch
    'Msgbox("Error , si continúa reinicié el teléfono","Error")
    Log(LastException.Message)
End Try

End Sub



y me marca el siguiente error en esta linea: tipo_i= parser.NextArray 'returns a list with maps


B4X:
NOMBRE.....geocoder
entro
Error occurred on line: 577 (principal)
java.lang.RuntimeException: JSON Array expected.
    at anywheresoftware.b4a.objects.collections.JSONParser.NextArray(JSONParser.java:62)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.BA$2.run(BA.java:360)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:158)
    at android.app.ActivityThread.main(ActivityThread.java:7224)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
java.lang.Exception:  java.lang.RuntimeException: JSON Array expected.


Alguien me puede orientar?

muchas gracias.
 

rscheel

Well-Known Member
Licensed User
Longtime User
hola estoy tratando de tomar este valor que saco de google

B4X:
{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "916",
               "short_name" : "916",
               "types" : [ "street_number" ]
            },
            {
               "long_name" : "Santo Domingo",
               "short_name" : "Santo Domingo",
               "types" : [ "route" ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "administrative_area_level_3", "political" ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Región Metropolitana",
               "short_name" : "Región Metropolitana",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Chile",
               "short_name" : "CL",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Santo Domingo 916, Santiago, Región Metropolitana, Chile",
         "geometry" : {
            "location" : {
               "lat" : -33.436248,
               "lng" : -70.65021899999999
            },
            "location_type" : "ROOFTOP",
            "viewport" : {
               "northeast" : {
                  "lat" : -33.4348990197085,
                  "lng" : -70.6488700197085
               },
               "southwest" : {
                  "lat" : -33.4375969802915,
                  "lng" : -70.6515679802915
               }
            }
         },
         "place_id" : "ChIJryKYQaPFYpYRjmNo8vl2i6Q",
         "types" : [ "street_address" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "PA262-Parada 2 / (M) Plaza De Armas",
               "short_name" : "PA262-Parada 2 / (M) Plaza De Armas",
               "types" : [
                  "bus_station",
                  "establishment",
                  "point_of_interest",
                  "transit_station"
               ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "administrative_area_level_3", "political" ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Región Metropolitana",
               "short_name" : "Región Metropolitana",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Chile",
               "short_name" : "CL",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "PA262-Parada 2 / (M) Plaza De Armas, Santiago, Región Metropolitana, Chile",
         "geometry" : {
            "location" : {
               "lat" : -33.4361383,
               "lng" : -70.65106059999999
            },
            "location_type" : "GEOMETRIC_CENTER",
            "viewport" : {
               "northeast" : {
                  "lat" : -33.4347893197085,
                  "lng" : -70.6497116197085
               },
               "southwest" : {
                  "lat" : -33.43748728029149,
                  "lng" : -70.6524095802915
               }
            }
         },
         "place_id" : "ChIJ5-rkWKPFYpYRpBfw9Uz4f7I",
         "types" : [
            "bus_station",
            "establishment",
            "point_of_interest",
            "transit_station"
         ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "administrative_area_level_3", "political" ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Región Metropolitana",
               "short_name" : "Región Metropolitana",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Chile",
               "short_name" : "CL",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Santiago, Región Metropolitana, Chile",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : -33.425617,
                  "lng" : -70.6251297
               },
               "southwest" : {
                  "lat" : -33.4811177,
                  "lng" : -70.7332574
               }
            },
            "location" : {
               "lat" : -33.4378305,
               "lng" : -70.6504492
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : -33.425617,
                  "lng" : -70.6251297
               },
               "southwest" : {
                  "lat" : -33.4811177,
                  "lng" : -70.7332574
               }
            }
         },
         "place_id" : "ChIJuzrymgbQYpYRl0jtCfRZnYc",
         "types" : [ "locality", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "colloquial_area", "locality", "political" ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Región Metropolitana",
               "short_name" : "Región Metropolitana",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Chile",
               "short_name" : "CL",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Santiago, Región Metropolitana, Chile",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : -33.2713874,
                  "lng" : -70.42678069999999
               },
               "southwest" : {
                  "lat" : -33.6741885,
                  "lng" : -70.8328819
               }
            },
            "location" : {
               "lat" : -33.4488897,
               "lng" : -70.66926549999999
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : -33.2713874,
                  "lng" : -70.42678069999999
               },
               "southwest" : {
                  "lat" : -33.6741885,
                  "lng" : -70.8328819
               }
            }
         },
         "place_id" : "ChIJL68lBEHFYpYRMQkPQDzVdYQ",
         "types" : [ "colloquial_area", "locality", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "administrative_area_level_3", "political" ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Región Metropolitana",
               "short_name" : "Región Metropolitana",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Chile",
               "short_name" : "CL",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Santiago, Región Metropolitana, Chile",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : -33.425617,
                  "lng" : -70.6251297
               },
               "southwest" : {
                  "lat" : -33.4785507,
                  "lng" : -70.6918738
               }
            },
            "location" : {
               "lat" : -33.45,
               "lng" : -70.66669999999999
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : -33.425617,
                  "lng" : -70.6251297
               },
               "southwest" : {
                  "lat" : -33.4785507,
                  "lng" : -70.6918738
               }
            }
         },
         "place_id" : "ChIJI8xkFgbFYpYRBYHTR-J6eXw",
         "types" : [ "administrative_area_level_3", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Santiago",
               "short_name" : "Santiago",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Región Metropolitana",
               "short_name" : "Región Metropolitana",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Chile",
               "short_name" : "CL",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Santiago, Región Metropolitana, Chile",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : -33.1025363,
                  "lng" : -70.17483899999999
               },
               "southwest" : {
                  "lat" : -33.62800259999999,
                  "lng" : -70.9577496
               }
            },
            "location" : {
               "lat" : -33.45,
               "lng" : -70.66669999999999
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : -33.1025363,
                  "lng" : -70.17483899999999
               },
               "southwest" : {
                  "lat" : -33.62800259999999,
                  "lng" : -70.9577496
               }
            }
         },
         "place_id" : "ChIJlVV_vxvJYpYRziXz-KE8chY",
         "types" : [ "administrative_area_level_2", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Región Metropolitana",
               "short_name" : "Región Metropolitana",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Chile",
               "short_name" : "CL",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Región Metropolitana, Chile",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : -32.919451,
                  "lng" : -69.7689943
               },
               "southwest" : {
                  "lat" : -34.2878148,
                  "lng" : -71.7088102
               }
            },
            "location" : {
               "lat" : -33.4375545,
               "lng" : -70.6504896
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : -32.919451,
                  "lng" : -69.7689943
               },
               "southwest" : {
                  "lat" : -34.2878148,
                  "lng" : -71.7088102
               }
            }
         },
         "place_id" : "ChIJUR74fWpvYpYR2oNLRG3CzWA",
         "types" : [ "administrative_area_level_1", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Chile",
               "short_name" : "CL",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Chile",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : -17.4983293,
                  "lng" : -66.3327
               },
               "southwest" : {
                  "lat" : -56.1455,
                  "lng" : -110.0281
               }
            },
            "location" : {
               "lat" : -35.675147,
               "lng" : -71.542969
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : -17.4983293,
                  "lng" : -66.3327
               },
               "southwest" : {
                  "lat" : -56.1455,
                  "lng" : -110.0281
               }
            }
         },
         "place_id" : "ChIJL68lBEHFYpYRHbkCERPhBQU",
         "types" : [ "country", "political" ]
      }
   ],
   "status" : "OK"
}

Lo intento de tomar asi desde b4a:
B4X:
Sub b_Click
    Dim miniruta As String
    miniruta="https://maps.googleapis.com/maps/api/geocode/json?latlng=-33.453454,-70.562686"

  

    geocoder_direccion.PostString(miniruta,"")
  
  
  
End Sub




'JOBDONE
Sub JobDone(Job As HttpJob)
Try



    Dim m As Map
    Dim respuesta,id,query,comentario,fecha,hora,iden_reporte,iden_reporte1,duplicado,tduplicado As String






    m.Initialize()

    Log("entramos....."&Job.Success)
    Log("mesaje "&Job.ErrorMessage)


    If Job.Success Then
        Dim res As String
        res = Job.GetString

        Log("Response from server: " & res)
        Dim parser As JSONParser







        parser.Initialize(res)

        Log("NOMBRE....."&Job.JobName)

        Select Job.JobName





            Case "geocoder"

               Log("entro")


                Dim tipo_i As List
                tipo_i= parser.NextArray 'returns a list with maps


                For i = 0 To tipo_i.Size - 1


                    Dim m As Map
                    m = tipo_i.Get(i)


                    respuesta= m.Get("results")
                    Log("xxx"&respuesta)
                  


                    m.Clear
                Next


        End Select
    Else






    End If
    Job.Release


Catch
    'Msgbox("Error , si continúa reinicié el teléfono","Error")
    Log(LastException.Message)
End Try

End Sub



y me marca el siguiente error en esta linea: tipo_i= parser.NextArray 'returns a list with maps


B4X:
NOMBRE.....geocoder
entro
Error occurred on line: 577 (principal)
java.lang.RuntimeException: JSON Array expected.
    at anywheresoftware.b4a.objects.collections.JSONParser.NextArray(JSONParser.java:62)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.BA$2.run(BA.java:360)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:158)
    at android.app.ActivityThread.main(ActivityThread.java:7224)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
java.lang.Exception:  java.lang.RuntimeException: JSON Array expected.


Alguien me puede orientar?

muchas gracias.

Revisa este tutorial de Erel https://www.b4x.com/android/forum/threads/android-json-tutorial.6923/#content
 
Top