AddItemArray

Description

Adds a child item of JsonArrayItem type in the JSON generator object.

Applies to

JSONGenerator objects

Syntax

objectname.AddItemArray ( ParentItemHandle )
objectname.AddItemArray ( ParentItemHandle, Key )
objectname.AddItemArray ( ParentItemPath )
objectname.AddItemArray ( ParentItemPath, Key )

Argument

Description

objectname

The name of the JSONGenerator object in which you want to add an item

ParentItemHandle

A long whose value is the handle of the parent item of JsonArrayItem or JsonObjectItem type

ParentItemPath

A string whose value is the path of the parent item of JsonArrayItem or JsonObjectItem type

Key

A string whose value is the key of the child item


Return value

Long.

Returns the handle of the new child item if it succeeds and -1 if an error occurs. If any argument's value is null, the method returns null.

Example 1

This example creates an array root item and adds an array child item. The result is [[101,102,103]].

Long ll_RootArray, ll_ChildArray
JsonGenerator lnv_JsonGenerator
lnv_JsonGenerator = Create JsonGenerator

// Create an array root item
ll_RootArray = lnv_JsonGenerator.CreateJsonArray()

// Add an array child item
ll_ChildArray = lnv_JsonGenerator.AddItemArray(ll_RootArray)
lnv_JsonGenerator.AddItemNumber(ll_ChildArray, 101)
lnv_JsonGenerator.AddItemNumber(ll_ChildArray, 102)
lnv_JsonGenerator.AddItemNumber(ll_ChildArray, 103)

Example 2

This example creates an object root item and adds an array child item. The result is {"id":[101,102,103]}.

Long ll_RootObject, ll_ChildArray
JsonGenerator lnv_JsonGenerator
lnv_JsonGenerator = Create JsonGenerator

// Create an object root item
ll_RootObject = lnv_JsonGenerator.CreateJsonObject()

// Add an array child item
ll_ChildArray = lnv_JsonGenerator.AddItemArray(ll_RootObject, "id")
lnv_JsonGenerator.AddItemNumber(ll_ChildArray, 101)
lnv_JsonGenerator.AddItemNumber(ll_ChildArray, 102)
lnv_JsonGenerator.AddItemNumber(ll_ChildArray, 103)

Example 3

This example creates an array root item and adds an array child item. The result is [[101,102,103]].

String ls_RootPath, ls_ChildPath
JsonGenerator lnv_JsonGenerator
lnv_JsonGenerator = Create JsonGenerator

// Creates an array root item
lnv_JsonGenerator.CreateJsonArray()
ls_RootPath = "/"

// Adds an array child item
lnv_JsonGenerator.AddItemArray(ls_RootPath)
ls_ChildPath = ls_RootPath + "1"
lnv_JsonGenerator.AddItemNumber(ls_ChildPath, 101)
lnv_JsonGenerator.AddItemNumber(ls_ChildPath, 102)
lnv_JsonGenerator.AddItemNumber(ls_ChildPath, 103)

Example 4

This example creates an object root item and adds an array child item. The result is {"id":[101,102,103]}.

String ls_RootPath, ls_ChildPath
JsonGenerator lnv_JsonGenerator
lnv_JsonGenerator = Create JsonGenerator

// Creates an object root item
lnv_JsonGenerator.CreateJsonObject()
ls_RootPath = "/"

// Adds an array child item
lnv_JsonGenerator.AddItemArray(ls_RootPath, "id")
ls_ChildPath = ls_RootPath + "id"
lnv_JsonGenerator.AddItemNumber(ls_ChildPath, 101)
lnv_JsonGenerator.AddItemNumber(ls_ChildPath, 102)
lnv_JsonGenerator.AddItemNumber(ls_ChildPath, 103)

See also

AddItemBlob

AddItemBoolean

AddItemDate

AddItemDateTime

AddItemNull

AddItemNumber

AddItemObject

AddItemString

AddItemTime