Skip to content

Member - cJsonObject

Gets a member of the JSON object by its name or array index

Type: Function
Return Data Type: Handle

Parameters

Parameter Type Description
sMember String Member name or array index

Syntax

Function Member String sMember Returns Handle

Call Example

Get Member sMember to HandleVariable

Description

Gets a member of the JSON object by its name or array index.

The JsonType and MemberJsonType functions can be used to determine the type of a specific node.

Sample

The example below shows how to parse a string with JSON. If successful it reads the age member from the details object. If not successful it uses ReportParseError that will generate an error.

Handle hoJson hoDetails
Boolean bSuccess
Integer iAge

Get Create (RefClass(cJsonObject)) to hoJson

Get ParseString of hoJson '{"name" : "John", "details" : {"age" : 31, "male" : true}}' to bSuccess
If (bSuccess) Begin
    Get Member of hoJson "details" to hoDetails

    Get MemberValue of hoDetails "age" to iAge

    Showln ("Age of John: " + String(iAge))

    Send Destroy of hoDetails
End
Else Begin
    Send ReportParseError of hoJson
End

Send Destroy of hoJson

See Also

MemberValue

Return Value

Hande of a member of the JSON object