Help with JSONParser and HTTPUtils

fpdianzen

Member
Licensed User
Longtime User
i have a webpage here needed to be parsed, it generates JSON but when i process it it stops and says "list needs to be initialized" here is my code thanks




B4X:
Sub abwifi1_FoundLocation()
Dim ResLocation As ABFoundLocation 
ResLocation  =abwifi1.ABGetFoundLocation()
mod1.latx = ResLocation.Latitude
mod1.longx = ResLocation.Longitude 
HttpUtils.CallbackActivity = "Map"
HttpUtils.CallbackJobDoneSub = "JobDone"
mod1.gecodex = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?"
Dim report As String 
report="location="& mod1.latx &","&mod1.longx&"&radius=5000&types=police&sensor=True&key=AIzaSyC83Ko8-MHYaxTqtDrNIsdExuPZ9bVRZnM"
HttpUtils.PostString("Job1",mod1.gecodex,report)
'urlx ="geo:"&mod1.latx &","&mod1.longx &"?q=police&radius=5000"'



End Sub
Sub JobDone (Job As String)
   If HttpUtils.IsSuccess(mod1.gecodex  ) Then
      Dim parser As JSONParser
      Dim response As String
      Dim Map1 As Map
      response = HttpUtils.GetString(mod1.gecodex )
      parser.Initialize(response)
      
      Dim rows As List
      rows = parser.NextArray
      
      'work with result
      'rows is a List. Each item is a Map with the columns names as keys and the db values as the values.
   If rows.Size <> 0 Then
      For i = 0 To rows.Size - 1
         Dim m As Map
         m = rows.Get(i)
      Next
   End If
      
   End If
   ProgressDialogHide 
   HttpUtils.Complete = False
End Sub


and here is a sample webpage for it
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=14.5544988,121.0232537&radius=5000&types=police&sensor=true&key=AIzaSyC83Ko8-MHYaxTqtDrNIsdExuPZ9bVRZnM
 
Top