Sample code for 30+ languages & platforms
Visual FoxPro

Load a JSON Array

See more JSON Examples

The Chilkat JSON API requires the top-level JSON to be an object. Therefore, to load an array requires that it first be wrapped as an object.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL lcJsonArrayStr
LOCAL loSbJson
LOCAL loJson
LOCAL loJArray
LOCAL loJObjId

lnSuccess = 0

* Imagine we want to load this JSON array for parsing:
lcJsonArrayStr = '[{"id":200},{"id":196}]'

* First wrap it in a JSON object by prepending "{ "array":" and appending "}"
loSbJson = CreateObject('Chilkat.StringBuilder')
loSbJson.Append('{"array":')
loSbJson.Append(lcJsonArrayStr)
loSbJson.Append("}")

loJson = CreateObject('Chilkat.JsonObject')
loJson.Load(loSbJson.GetAsString())

* Now we can get the JSON array
loJArray = loJson.ArrayAt(0)

* Do what you want with the JSON array...
* For example:
loJObjId = loJArray.ObjectAt(0)
? STR(loJObjId.IntOf("id"))
RELEASE loJObjId

RELEASE loJArray

RELEASE loSbJson
RELEASE loJson