GetItemDateTime

Syntax 1: GetItemDateTime ( ItemHandle )

Syntax 2: GetItemDateTime ( ParentItemHandle, Key )

Syntax 3: GetItemDateTime ( ItemPath )

Syntax 1

Description

Gets the value of the item whose type is datetime.

Applies to

JSONParser objects

Syntax

objectname.GetItemDateTime ( ItemHandle )

Argument

Description

objectname

The name of the JSONParser object whose item value you want to obtain.

ItemHandle

A long whose value is the handle of the item of JsonStringItem or JsonNumberItem type.


Return value

DateTime.

Returns the datetime value of the item if it succeeds; if any argument's value is null, returns null; if an error occurs, the SystemError event will be triggered.

If the item value is a number (UTC timestamp), the returned datetime value will be the local datetime converted by using the local timezone. If the item value is a string, the returned datetime value will be the datetime without timezone conversion.

Usage

If the item value is null, this function will throw an error, therefore, it is recommended that before executing this function, call GetItemType to check if the item value is null. See example 2 in GetItemArray.

Examples

This example gets the value of the first item:

JsonParser lnv_JsonParser
String ls_Json
DateTime ldt_datetime
Long ll_RootObject, ll_item
lnv_JsonParser = Create JsonParser

ls_Json = '{"datetime":7234930293, "date": "2017-09-21", "time": "12:00:00"}'

lnv_JsonParser.LoadString(ls_Json)
ll_RootObject = lnv_JsonParser.GetRootItem()
ll_item = lnv_JsonParser.GetChildItem(ll_RootObject, 1)
ldt_datetime = lnv_JsonParser.GetItemDateTime(ll_item)

Syntax 2

Description

Gets the value of the item whose type is datetime.

Applies to

JSONParser objects

Syntax

objectname.GetItemDateTime ( ParentItemHandle, Key )

Argument

Description

objectname

The name of the JSONParser object whose child item value you want to obtain.

ParentItemHandle

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

Key

A string whose value is the key of the child item of JsonStringItem and JsonNumberItem type. For the JsonStringItem type, formats such as "yyyy-mm-dd hh:mm:ss" are supported.


Return value

DateTime.

Returns the datetime value of the child item if it succeeds; if any argument's value is null, returns null; if an error occurs, the SystemError event will be triggered.

If the item value is a number (UTC timestamp), the returned datetime value will be the local datetime converted by using the local timezone. If the item value is a string, the returned datetime value will be the datetime without timezone conversion.

Usage

If the item value is null, this function will throw an error, therefore, it is recommended that before executing this function, call GetItemType to check if the item value is null. See example 2 in GetItemArray.

Examples

This example gets the value of the "datetime" item:

JsonParser lnv_JsonParser
String ls_Json
DateTime ldt_datetime
Long ll_RootObject
lnv_JsonParser = Create JsonParser

ls_Json = '{"datetime":7234930293, "date": "2017-09-21", "time": "12:00:00"}'

lnv_JsonParser.LoadString(ls_Json)
ll_RootObject = lnv_JsonParser.GetRootItem()
ldt_datetime = lnv_JsonParser.GetItemDateTime(ll_RootObject, "datetime")

Syntax 3

Description

Gets the value of the item whose type is datetime.

Applies to

JSONParser objects

Syntax

objectname.GetItemDateTime ( ItemPath )

Argument

Description

objectname

The name of the JSONParser object whose item value you want to obtain.

ItemPath

A string whose value is the path of the item of JsonStringItem or JsonNumberItem type. If there is a multi-dimensional array, use the number to indicate the order of the array. If a key name contains "/", use the escape character "~~/" to replace "/".


Return value

DateTime.

Returns the datetime value of the item if it succeeds; if any argument's value is null, returns null; if an error occurs, the SystemError event will be triggered.

If the item value is a number (UTC timestamp), the returned datetime value will be the local datetime converted by using the local timezone. If the item value is a string, the returned datetime value will be the datetime without timezone conversion.

Usage

If the item value is null, this function will throw an error, therefore, it is recommended that before executing this function, call GetItemType to check if the item value is null. See example 2 in GetItemArray.

Examples

This example gets the value of the first item according to its item path:

JsonParser lnv_JsonParser
String ls_Json, ls_Path
DateTime ldt_datetime
lnv_JsonParser = Create JsonParser

ls_Json = '{"datetime":7234930293, "date": "2017-09-21", "time": "12:00:00"}'

lnv_JsonParser.LoadString(ls_Json)
ls_Path = "/datetime"
ldt_datetime = lnv_JsonParser.GetItemDateTime(ls_Path)

See also

GetItemArray

GetItemArrayJSONString

GetItemBlob

GetItemBoolean

GetItemByPath

GetItemDate

GetItemDecimal

GetItemNumber

GetItemObject

GetItemObjectJSONString

GetItemString

GetItemTime

GetItemType

GetNumberType