JSONParser object

The JSONParser object provides the ability to load the JSON-formatted data from a string or from a TXT file into a JSON object, and then parse the JSON object to get the child item count, get the handle, key name or value of any specified item, etc.

Note

It is not supported to use this object to process large data (20 MB or 100,000 data rows can be considered as large data based on our tests), because this object will call a third-party library which is memory intensive.

Note

JSONParser (as well as HTTPClient, RESTClient, CrypterObject, CoderObject, CompressorObject, DotNetAssembly, JSONGenerator, JSONPackage, OAuthClient, PDF Builder objects, SMTPClient, PowerServerLabel, PowerServerResult) does not support multi-threading.

Properties

JSONParser property

Datatype

Description

ClassDefinition

PowerObject

An object of type PowerObject containing information about the class definition of the object or control.

ReturnsNullWhenError

Boolean

Specifies whether the getting item function returns a null value when error occurs.


Events

JSONParser event

Occurs

Constructor

Immediately before the Open event occurs in the window

Destructor

Immediately after the Close event occurs in the window


Functions

JSONParser function

Datatype returned

Description

ClassName

String

Returns the name assigned to the object.

ContainsKey

Boolean

Checks if the key name exists.

ContainsPath

Boolean

Checks if the item path exists.

GetChildCount

Long

Gets the child item count.

GetChildItem

Long

Gets the child item handle.

GetChildKey

String

Gets the key name of child item.

GetContextService

Integer

Creates a reference to a context-specific instance of the specified service.

GetItemArray

Long

Gets the handle value of the child array item.

GetItemArrayJSONString

String

Gets the string value of the item whose type is array.

GetItemBlob

Blob

Gets the blob value of the item.

GetItemBoolean

Boolean

Gets the boolean value of the item.

GetItemByPath

Long

Gets the handle of the item.

GetItemDate

Date

Gets the date value of the item.

GetItemDateTime

DateTime

Gets the datetime value of the item.

GetItemDecimal

Decimal

Gets the decimal value of the item.

GetItemNumber

Double

Gets the double value of the item.

GetItemObject

Long

Gets the handle value of the child object item.

GetItemObjectJSONString

String

Gets the string value of the child object item.

GetItemString

String

Gets the string value of the item.

GetItemTime

Time

Gets the time value of the item.

GetItemType

JSONItemType

(enumerated)

Gets the type of item. Values are:

  • JsonStringItem! -- Type of the JSON node whose key value pair is a string, such as "name":"evan".

  • JsonNumberItem! -- Type of the JSON node whose key value pair is a number, such as "id":1001.

  • JsonBooleanItem! -- Type of the JSON node whose key value pair is a boolean, such as "active":true.

  • JsonNullItem! -- Type of the JSON node whose key value pair is null, such as "remark":null.

  • JsonObjectItem! -- Type of the JSON node whose key value pair is an object, such as "date_object":{"datetime":7234930293, "date": "2017-09-21", "time": "12:00:00"}.

  • JsonArrayItem! -- Type of the JSON node whose key value pair is an array, such as "department_array":[999999, {"name":"Website"}, {"name":"PowerBuilder"}, {"name":"IT"}].

GetNumberType

JSONNumberType

(enumerated)

Gets the type of the number item. Values are:

  • JsonNumber! -- Type of the JSON valid number.

  • JsonNaN! -- Type of the JSON invalid number.

  • JsonPositiveInfinity! -- Type of the JSON positive infinity.

  • JsonNegativeInfinity! -- Type of the JSON negative infinity.

GetParent

PowerObject

Returns a reference to the name of the parent object.

GetRootItem

Long

Gets the root item handle.

LoadFile

String

Loads a JSON file. The JSON file cannot contain special characters such as ~r~n or ~t, otherwise, LoadFile will throw the error "Invalid encoding in string".

LoadString

String

Loads a JSON string. The JSON string cannot contain special characters such as ~r~n or ~t, otherwise, LoadString will throw the error "Invalid encoding in string".

PostEvent

Boolean

Adds an event to the end of the message queue for the object.

TriggerEvent

Integer

Triggers a specific event in the object and executes the script for the event.

TypeOf

Object

Returns the type of the object.