AddItemString

Description

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

Applies to

JSONGenerator objects

Syntax

objectname.AddItemString ( ParentItemHandle, Value )
objectname.AddItemString ( ParentItemHandle, Key, Value )
objectname.AddItemString ( ParentItemPath, Value )
objectname.AddItemString ( ParentItemPath, Key, Value )

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

Value

A string whose value is the value 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 item and then adds a string child item:

JsonGenerator lnv_JsonGenerator
Long ll_RootArray
lnv_JsonGenerator = Create JsonGenerator

ll_RootArray = lnv_JsonGenerator.CreateJsonArray()
lnv_JsonGenerator.AddItemString(ll_RootArray, "string")

Example 2

This example creates an object item and then adds a string child item:

JsonGenerator lnv_JsonGenerator 
Long ll_RootObject
lnv_JsonGenerator = Create JsonGenerator

ll_RootObject = lnv_JsonGenerator.CreateJsonObject ()
lnv_JsonGenerator.AddItemString(ll_RootObject, "string", "value")

Example 3

This example creates an array item and then adds a string child item:

JsonGenerator lnv_JsonGenerator
String ls_RootPath
lnv_JsonGenerator = Create JsonGenerator

lnv_JsonGenerator.CreateJsonArray()
ls_RootPath = "/"
lnv_JsonGenerator.AddItemString(ls_RootPath, "string")

Example 4

This example creates an object item and then adds a string child item:

JsonGenerator lnv_JsonGenerator 
String ls_RootPath
lnv_JsonGenerator = Create JsonGenerator

lnv_JsonGenerator.CreateJsonObject ()
ls_RootPath = "/"
lnv_JsonGenerator.AddItemString(ls_RootPath, "string", "value")

See also

AddItemArray

AddItemBlob

AddItemBoolean

AddItemDate

AddItemDateTime

AddItemNull

AddItemNumber

AddItemObject

AddItemTime