Sample code for 30+ languages & platforms
PowerBuilder

Create JSON Document

See more JSON Examples

Sample code to create the following JSON document:
{
  "Title": "Pan's Labyrinth",
  "Director": "Guillermo del Toro",
  "Original_Title": "El laberinto del fauno",
  "Year_Released": 2006
}

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Json

li_Success = 0

loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
if li_rc < 0 then
    destroy loo_Json
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// The only reason for failure in the following lines of code would be an out-of-memory condition..

// An index value of -1 is used to append at the end.
li_Success = loo_Json.AddStringAt(-1,"Title","Pan's Labyrinth")
li_Success = loo_Json.AddStringAt(-1,"Director","Guillermo del Toro")
li_Success = loo_Json.AddStringAt(-1,"Original_Title","El laberinto del fauno")
li_Success = loo_Json.AddIntAt(-1,"Year_Released",2006)

loo_Json.EmitCompact = 0
Write-Debug loo_Json.Emit()


destroy loo_Json