SaveJson Method (XDATA)
9.8A
The SaveJson method stores the XDATA nodes as a JSON formatted string into a file. The method uses the following format:
|
|
|
|
Where:
Flags Affected: EOS, OVER, ZERO
Note the following:
The ZERO flag is set if the {return} value is zero.
The OVER flag is set TRUE if the {return} variable is too small where the returned value is truncated.
The EOS flag is always cleared.
The *OPTIONS {mask} values are defined as follows:
|
Value |
Description |
|
0x2 |
This bit value causes JSON constructs to be indented. |
|
0x4 |
This bit value causes the JSON lines to output with a terminating <CR>+<LF> end of record sequence. |
|
0x40 |
This bit value causes the TAB (0x09) character to be used when the indent mask bit (0x2) is being used. If this bit is turned off, a blank (0x20) character is used for the indent operations. |
The XDATA is converted to a JSON stream using the following rules:
JSON
only uses the DOM_ATTRIBUTE_NODE, DOM_ELEMENT_NODE, and DOM_TEXT_NODE nodes from the XDATA. Any other
DOM node types are ignored.
A
JSON array is a DOM_ELEMENT_NODE with a label of array and jsontype of JSON_TYPE_ARRAY. It can have multiple
DOM_TEXT_NODE as values and multiple DOM_ELEMENT_NODE as object values.
A
JSON object is a DOM_ELEMENT_NODE with a label of object and jsontype of JSON_TYPE_OBJECT. It can have
multiple DOM_ATTRIBUTE_NODE and DOM_ELEMENT_NODE nodes as key value pairs.
See
the following link for basic JSON syntax elements and rules:
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.
This method can return these values:
|
Value |
Meaning |
|
0 |
XDATA_ERR_NONE (Success) |
|
16 |
XDATA_ERR_FILE_CREATE |
|
17 |
XDATA_ERR_FILE_TOO_BIG |
|
18 |
XDATA_ERR_BAD_WRITE |
See Also: XDATA, XDATA Methods, Method Syntax
![]() |