Sample code for 30+ languages & platforms
Visual FoxPro Requires Chilkat v11.4.0+

Example: JsonObject.NewObjectOf method

Demonstrates the NewObjectOf method.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL lcCar
LOCAL loJson

lnSuccess = 0

lcCar = '{"make":"Toyota","model":"Camry","year":2022,"color":"silver","engine":{"type":"inline-4","fuel":"gasoline","horsepower":203},"features":["bluetooth","backup camera","adaptive cruise control","lane assist"],"isElectric":false}'

loJson = CreateObject('Chilkat.JsonObject')

loJson.UpdateString("test","abc")

lnSuccess = loJson.NewObjectOf("car",lcCar)
IF (lnSuccess = 0) THEN
    ? loJson.LastErrorText
    RELEASE loJson
    CANCEL
ENDIF

loJson.EmitCompact = 0
? loJson.Emit()

*  Result:

*  {
*    "test": "abc",
*    "car": {
*      "make": "Toyota",
*      "model": "Camry",
*      "year": 2022,
*      "color": "silver",
*      "engine": {
*        "type": "inline-4",
*        "fuel": "gasoline",
*        "horsepower": 203
*      },
*      "features": [
*        "bluetooth",
*        "backup camera",
*        "adaptive cruise control",
*        "lane assist"
*      ],
*      "isElectric": false
*    }
*  }

RELEASE loJson