LoadJson Method (XDATA)


9.8A

 

The LoadJson method loads JSON data into a XDATA object. The input data can be loaded directly from a DIM variable or from a specified file that contains a valid JSON stream. The new JSON data replaces all currently existing data in the XDATA object. The method uses the following format:

 

[label]

{object}.LoadJson

[GIVING {return}] using *Data={data}[,*Options={mask}]

Where:

label
Optional. A Program Execution Label.
object
Required. An XDATA object.
return
Optional. A Numeric Variable that receives a value to signify a pass or fail condition for the method execution.
data
Required. A Character String Variable or literal that that specifies a fully qualified path and file name that contains the JSON data stream. Additionally, the {data} string value can be the actual JSON data stream.
mask
Optional. A Numeric Variable or decimal number that specifies a bit mask value to control the operations of this method.

Flags Affected: EOS, OVER, ZERO

Note the following:

  1. The ZERO flag is set if the {return} value is zero.

  2. The OVER flag is set TRUE if the {return} variable is too small where the returned value is truncated.

  3. The EOS flag is always cleared.

  4. The *OPTIONS {mask} values are defined as follows:

  5.  

    Value

    This bit value ...

    0x1

    indicates that the {data} method parameter contains a path and file name which contains the JSON data to be loaded.

    0x2

    causes the JSON data file to be opened in read only mode.

    0x4

    allows JavaScript style comments in the JSON data being loaded.

     

  6. The {return} value is a zero if the method execution is successful. Otherwise, a non-zero value is returned to indicate an error has occurred. See the XDATA Method Return Values for more details.

  7. This method can return these values:

  8.  

    Value

    Meaning

    0

    XDATA_ERR_NONE (Success)

    1

    XDATA_ERR_NO_MEM

    12

    XDATA_ERR_OPEN_FAILED

    13

    XDATA_ERR_PARSER_CREATE

    14

    XDATA_ERR_PARSE

 

 

See Also: XDATA, XDATA Methods, Method Syntax



PL/B Language Reference GetType Method (XDATA) LoadXml Method (XDATA)