jsonToStruct
Convert a JSON text to a Struct.
jsonToStruct StructTarget,
JsonSource
Example: jsonToStruct vStruct,
myjson.txt
Parameters
Parameter | Data Type | Description |
---|---|---|
StructTarget | struct or any | Variable, parameter, or non-database field to hold the generated Struct |
JsonSource | string | JSON text to parse. It can be a string,
variable, or field, or the name of a file containing the JSON text. The JSON text must begin with an opening
bracket ( If a file is specified, it must be Unicode-encoded. If this is not the case, use fileload to first read the file into a Uniface variable or field, and then provide it as the JsonDocument parameter. |
Return Values
If the conversion was successful, a Struct representing the JSON text is returned in StructTarget (replacing the existing Struct it may have held).
Value | Meaning |
---|---|
0
|
Conversion was successful. |
<0 |
Conversion failed. $procerror contains the exact error. |
Common Errors
Error Number | Error Constant | Meaning |
---|---|---|
-4
|
IOSERR_OPEN_FAILURE
|
The file specified by JsonSource could not be opened |
-13
|
UIOSERR_OS_COMMAND
|
The specified file name specified by JsonDocument is too long. |
-1900
|
JSONERR_NO_CONTENT
|
Failed to load JSON string Occurs if the contents of the file are empty or if no JSON string is available after stripping leading and trailing whitespace. |
-1901
|
JSONERR_NO_TEXT
|
JSON text does not start with object or
array A JSON text must begin with
|
-1902
|
UJSONERR_PARSER
|
JSON parser returned an error. Additional
information is provided by the parser in $procErrorContext. Non-fatal warnings about conditions that
may be errors are returned in the |
Use
Allowed in all component types.
Version | Change |
---|---|
9.6.04 | Introduced |