Skip to content

ParseString - cJsonObject

Parses a string of JSON into a JSON object structure

Type: Function
Return Data Type: Boolean

Parameters

Parameter Type Description
sData String JSON data to parse (escaped string)

Syntax

Function ParseString String sData Returns Boolean

Call Example

Get ParseString sData to BooleanVariable

Description

Parses a string of JSON into a JSON object structure, where the object instance on which it is called is represents the outermost JSON object.

Use ReportParseError or psParseError to get parsing errors if False was returned.

Sample

Struct tPerson
    String first
    String last
    String greeting
End_Struct

Procedure OnClick
    String sJSON
    Handle hoJSON
    Boolean bRet
    tPerson person

    Move '{"first": "John","last": "Smith","greeting":' to sJSON
    Move (sJSON + '"Hello, \"World\""}') to sJSON

    Get Create (RefClass(cJsonObject)) to hoJSON
    Get ParseString of hoJSON sJSON to bRet

    If (bRet) Begin
        Get JsonToDataType of hoJSON to person
    End
End_Procedure

See Also

ParseUtf8

Return Value

True if the JSON was successfully parsed, False if not.