Json Troubles - Cannot compile

henrywood

Active Member
Licensed User
Longtime User
I am having problems with getting this code to compile:

B4X:
Sub hc_responsesuccess(Response As HttpResponse, TaskId As Int)

   ' OK ?
   If Response.StatusCode <> 200 Then
      Msgbox("Kunne ikke forbinde til FOF server ! [Fejl: " & Response.StatusCode & "]", "FEJL !")
      Activity.Finish()
   End If

   Dim p As String
   Dim e As String
   Dim n As String
   Dim m As Map
   Dim pn As String

   'ProgressDialogHide
   Dim res As String
   res = Response.GetString("UTF8")
   Msgbox(res,"Results")
   
   ' Parse the response here and fill the spinner and build our internal lists
   jsonP.Initialize(res)
   Map1 = jsonP.NextArray
   
   enhedsNr.Clear()

   For i = 0 To Map1.Size - 1
   
       m = Map1.Get(i)
      e = m.Get("EnhedNr")
      p = m.Get("Postnr")
      n = m.Get("Bynavn")
      
      pn = p & " " & n
      
                'The next line yields Input string was not in correct format' ??? - enhedsNr is a Spinner Object/Type
      enhedsNr.Add(pn);
      enhedsNavne.Add(n)
      enhedsNumre.Add(e)
      byer.Add(n)
       Log("Postnr: " & p & " - Value: " & e & " - By: " & n)
      
   Next      
   
   enhedsNr.SelectedIndex = 0
   
End Sub

Can someone please help ?

The json is an array of objects (where each object has the properties bynavn, enhednr and Postnr.

I am pretty new at this B4A thing...


Kind regards,


Henrik
 
Last edited:

henrywood

Active Member
Licensed User
Longtime User
Found the error myself - It was a ; on the errneous line (I am used to other languages requiring it should it is in the fingers )


Sorry
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…