AddItemNumber

Description

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

Applies to

JSONGenerator objects

Syntax

objectname.AddItemNumber ( ParentItemHandle, Value )
objectname.AddItemNumber ( ParentItemHandle, Key, Value )
objectname.AddItemNumber ( ParentItemHandle, Type )
objectname.AddItemNumber ( ParentItemHandle, Key, Type )
objectname.AddItemNumber ( ParentItemPath, Value )
objectname.AddItemNumber ( ParentItemPath, Key, Value )
objectname.AddItemNumber ( ParentItemPath, Type )
objectname.AddItemNumber ( ParentItemPath, Key, Type )

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 double whose value is the value of the child item

Type

A JsonNumberType whose value is the value type of the child item. If the type is JsonNumber!, the value will be converted to number 0.


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 a child item of number type:

JsonGenerator lnv_JsonGenerator
Long ll_RootArray
lnv_JsonGenerator = Create JsonGenerator

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

// Adds a number child item
lnv_JsonGenerator.AddItemNumber(ll_RootArray, 100)

Example 2

This example creates an object root item and adds a child item of number type:

JsonGenerator lnv_JsonGenerator
Long ll_RootObject
lnv_JsonGenerator = Create JsonGenerator

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

// Adds a number child item
lnv_JsonGenerator.AddItemNumber(ll_RootObject, "year", 2017)

Example 3

This example creates an array root item and adds three child items of number type:

JsonGenerator lnv_JsonGenerator
JsonNumberType ljsn_Type
Long ll_RootArray
lnv_JsonGenerator = Create JsonGenerator

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

// Adds NaN, Infinity, -Infinity number child items
ljsn_Type = JsonNaN!
lnv_JsonGenerator.AddItemNumber(ll_RootArray, ljsn_Type)
ljsn_Type = JsonPositiveInfinity!
lnv_JsonGenerator.AddItemNumber(ll_RootArray, ljsn_Type)
ljsn_Type = JsonNegativeInfinity!
lnv_JsonGenerator.AddItemNumber(ll_RootArray, ljsn_Type)

Example 4

This example creates an object root item and adds three child items of number type:

JsonGenerator lnv_JsonGenerator
JsonNumberType ljsn_Type
Long ll_RootObject
lnv_JsonGenerator = Create JsonGenerator

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

// Adds NaN, Infinity, -Infinity number child items
ljsn_Type = JsonNaN!
lnv_JsonGenerator.AddItemNumber(ll_RootObject, "NaN", ljsn_Type)
ljsn_Type = JsonPositiveInfinity!
lnv_JsonGenerator.AddItemNumber(ll_RootObject, "PositiveInfinity", ljsn_Type)
ljsn_Type = JsonNegativeInfinity!
lnv_JsonGenerator.AddItemNumber(ll_RootObject, "NegativeInfinity", ljsn_Type)

Example 5

This example creates an array root item and adds a child item of number type:

JsonGenerator lnv_JsonGenerator
String ls_Path
lnv_JsonGenerator = Create JsonGenerator

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

// Adds a number child item
lnv_JsonGenerator.AddItemNumber(ls_Path, 100)

Example 6

This example creates an object root item and adds a child item of number type:

JsonGenerator lnv_JsonGenerator
String ls_Path
lnv_JsonGenerator = Create JsonGenerator

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

// Adds a number child item
lnv_JsonGenerator.AddItemNumber(ls_Path, "year", 2017)

Example 7

This example creates an array root item and adds three child items of number type:

JsonGenerator lnv_JsonGenerator
JsonNumberType ljsn_Type
String ls_Path
lnv_JsonGenerator = Create JsonGenerator

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

// Adds NaN, Infinity, -Infinity number child item
ljsn_Type = JsonNaN!
lnv_JsonGenerator.AddItemNumber(ls_Path, ljsn_Type)
ljsn_Type = JsonPositiveInfinity!
lnv_JsonGenerator.AddItemNumber(ls_Path, ljsn_Type)
ljsn_Type = JsonNegativeInfinity!
lnv_JsonGenerator.AddItemNumber(ls_Path, ljsn_Type)

Example 8

This example creates an object root item and adds three child items of number type:

JsonGenerator lnv_JsonGenerator
JsonNumberType ljsn_Type
String ls_Path
lnv_JsonGenerator = Create JsonGenerator

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

// Adds NaN, Infinity, -Infinity number child item
ljsn_Type = JsonNaN!
lnv_JsonGenerator.AddItemNumber(ls_Path, "NaN", ljsn_Type)
ljsn_Type = JsonPositiveInfinity!
lnv_JsonGenerator.AddItemNumber(ls_Path, "PositiveInfinity", ljsn_Type)
ljsn_Type = JsonNegativeInfinity!
lnv_JsonGenerator.AddItemNumber(ls_Path, "NegativeInfinity", ljsn_Type)

See also

AddItemArray

AddItemBlob

AddItemBoolean

AddItemDate

AddItemDateTime

AddItemNull

AddItemObject

AddItemString

AddItemTime