Description
Adds a child item of JsonStringItem or JsonNumberItem type in the JSON generator object.
Applies to
Syntax
objectname.AddItemDateTime ( ParentItemHandle, Value )
objectname.AddItemDateTime ( ParentItemHandle, Value, Flag )
objectname.AddItemDateTime ( ParentItemHandle, Key, Value )
objectname.AddItemDateTime ( ParentItemHandle, Key, Value, Flag )
objectname.AddItemDateTime ( ParentItemPath, Value )
objectname.AddItemDateTime ( ParentItemPath, Value, Flag )
objectname.AddItemDateTime ( ParentItemPath, Key, Value )
objectname.AddItemDateTime ( ParentItemPath, Key, Value, Flag )
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 datetime whose value is the value of the child item. |
Flag |
A boolean whose value is the type of the child item. True -- JsonNumberItem type. A JsonNumberItem type value is a UTC timestamp converted from the local time using the local timezone. False -- JsonStringItem type. A JsonStringItem type value is a string converted from the local time directly (no timezone conversion). |
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 DateTime child item. The result is like this: ["2017-12-09 12:15:00"]. The datetime value is formatted according to the Windows regional settings.
Long ll_RootArray JsonGenerator lnv_JsonGenerator lnv_JsonGenerator = Create JsonGenerator // Creates an array root item ll_RootArray = lnv_JsonGenerator.CreateJsonArray() // Adds a DateTime child item lnv_JsonGenerator.AddItemDateTime(ll_RootArray, datetime("2017-12-09 12:15:00"))
Example 2
This example creates an array root item and adds a DateTime child item with and without timezone conversion.
Long ll_RootArray JsonGenerator lnv_JsonGenerator lnv_JsonGenerator = Create JsonGenerator // Creates an array root item ll_RootArray = lnv_JsonGenerator.CreateJsonArray() // Adds a DateTime child item lnv_JsonGenerator.AddItemDateTime(ll_RootArray, datetime("2017-12-09 12:15:00"), false) //Result is ["2017-12-09 12:15:00"] lnv_JsonGenerator.AddItemDateTime(ll_RootArray, datetime("2017-12-09 12:15:00"), true) //Result is [1512821700]
Example 3
This example creates an object root item and adds a DateTime child item. The result is like this: {"datetime":"2017-12-09 12:15:00"}. The datetime value is formatted according to the Windows regional settings.
Long ll_RootObject JsonGenerator lnv_JsonGenerator lnv_JsonGenerator = Create JsonGenerator // Creates an object root item ll_RootObject = lnv_JsonGenerator.CreateJsonObject () // Adds a DateTime child item lnv_JsonGenerator.AddItemDateTime(ll_RootObject, "datetime", datetime("2017-12-09 12:15:00"))
Example 4
This example creates an object root item and adds a DateTime child item using the local timezone conversion.
Long ll_RootObject JsonGenerator lnv_JsonGenerator lnv_JsonGenerator = Create JsonGenerator // Creates an object root item ll_RootObject = lnv_JsonGenerator.CreateJsonObject () // Adds a DateTime child item lnv_JsonGenerator.AddItemDateTime(ll_RootObject, "datetime", datetime("2017-12-09 12:15:00"), true)
Example 5
This example creates an array root item and adds a DateTime child item. The result is like this: ["2017-12-09 12:15:00"]. The datetime value is formatted according to the Windows regional settings.
String ls_Path JsonGenerator lnv_JsonGenerator lnv_JsonGenerator = Create JsonGenerator // Creates an array root item lnv_JsonGenerator.CreateJsonArray() ls_Path = "/" // Adds a DateTime child item lnv_JsonGenerator.AddItemDateTime(ls_Path, datetime("2017-12-09 12:15:00"))
Example 6
This example creates an array root item and adds a DateTime child item with and without timezone conversion.
String ls_Path JsonGenerator lnv_JsonGenerator lnv_JsonGenerator = Create JsonGenerator // Creates an array root item lnv_JsonGenerator.CreateJsonArray() ls_Path = "/" // Adds a DateTime child item lnv_JsonGenerator.AddItemDateTime(ls_Path, datetime("2017-12-09 12:15:00"), false) //Result is ["2017-12-09 12:15:00"] lnv_JsonGenerator.AddItemDateTime(ls_Path, datetime("2017-12-09 12:15:00"), true) //Result is [1512821700]
Example 7
This example creates an object root item and adds a DateTime child item. The result is like this: {"datetime":"2017-12-09 12:15:00"}. The datetime value is formatted according to the Windows regional settings.
String ls_Path JsonGenerator lnv_JsonGenerator lnv_JsonGenerator = Create JsonGenerator // Creates an object root item lnv_JsonGenerator.CreateJsonObject() ls_Path = "/" // Adds a DateTime child item lnv_JsonGenerator.AddItemDateTime(ls_Path, "datetime", datetime("2017-12-09 12:15:00"))
Example 8
This example creates an object root item and adds a DateTime child item using the local timezone conversion.
String ls_Path JsonGenerator lnv_JsonGenerator lnv_JsonGenerator = Create JsonGenerator // Creates an object root item lnv_JsonGenerator.CreateJsonObject () ls_Path = "/" // Adds a DateTime child item lnv_JsonGenerator.AddItemDateTime(ls_Path, "datetime", datetime("2017-12-09 12:15:00"), true)
See also