This is my return JSON from PHP :
This is my code in B4A :
I'm expecting Rtext will return :
tedy;21;888
tom;23;cat
bunny;22;carrot
But I got Rtext :
tedy;21;888
tedy;21;888
tedy;21;888
How to move to next data in JSON map ? What did I do wrong ?
B4X:
[{"ID":"21","username":"tedy","password":"888"},{"ID":"23","username":"tom","password":"cat"},{"ID":"22","username":"bunny","password":"carrot"}]
This is my code in B4A :
B4X:
Sub Globals
Dim hc As HttpClient
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
hc.Initialize("hc")
End If
End Sub
Sub ButtonOk_Click
Dim post As HttpRequest
post.InitializeGet("http://192.168.0.11/testandroid/where.php")
hc.Execute(post, 2)
End Sub
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
If TaskId = 1 Then
'Do some other code
Else If TaskId =2 Then
ToastMessageShow("Processing", True)
Dim result,Uname, Pwd, Rtext As String
Dim JSON As JSONParser
Dim m As Map
Dim ID, zie, i As Int
result = Response.GetString("UTF8")
result = result.SubString2( 3, result.Length - 3)
JSON.Initialize(result)
m = JSON.NextObject
zie = m.Size
For i = 0 To m.Size - 1
m.Get(i)
Rtext = Rtext & m.Get("username") & ";" & m.Get("ID") & ";" & m.Get("password") & CRLF
Next
End if
End Sub
I'm expecting Rtext will return :
tedy;21;888
tom;23;cat
bunny;22;carrot
But I got Rtext :
tedy;21;888
tedy;21;888
tedy;21;888
How to move to next data in JSON map ? What did I do wrong ?