B4X Requires Chilkat v11.0.0+
B4X
Load JSON Array from HTTP Response Body
Demonstrates how to load the HTTP response body directly into a JsonArray.Chilkat B4X Downloads
Dim success As Boolean = False
Dim http As ChilkatHttp
http.Initialize("http")
Dim resp As ChilkatHttpResponse
resp.Initialize
success = http.HttpStr("GET", "https://www.chilkatsoft.com/exampledata/sampleArray.json", "", "", "", resp)
If success = False Then
Log(http.LastErrorText)
Return
End If
' A JSON array is JSON that begins with "[" and ends with "]"
Dim jarr As ChilkatJsonArray
jarr.Initialize
' If we wish to transfer (instead of copy) the JSON from the HttpResponse to the JsonArray, then add the keyword "TakeResponseBody" to UncommonOptions
' This could save memory for extremely large JSON responses.
resp.UncommonOptions = "TakeResponseBody"
resp.GetBodyJarr(jarr)
Log(jarr.Emit)
' Note: If UncommonOptions contained "TakeResponseBody", then the response BodyStr will now be empty:
Log("----")
Log(resp.BodyStr)