Function Json2Var() Foundation

Converts JSON text to a value of the corresponding data type.

Syntax
Json2Var( <cJson> ) -> aoData
Parameters
<cJson>
<cJson> is a character string with JSON text encoded as UTF-8.
Return

The value specified in the JSON text as an array or object.

Description

The function Json2Var() converts a value specified in JavaScript Object Notation (JSON) text to its corresponding Xbase++ data type. If <cJson> cannot be converted, a runtime error is raised.

JSON is a lightweight data exchange format. It is easy for people to read and write and is based on a subset of the JavaScript programming language. JSON is a text format that is completely programming language independent. These features make JSON an ideal data exchange language for web applications.

JSON is based on two structures:

- A collection of name/value pairs. In Xbase++, this is represented by an instance of the class DataObject.

- An ordered list of values. In Xbase++, this is represented as an array.

The string in <cJson> must be UTF-8 encoded. Passing an UTF-16 or UTF-32 encoded string to Json2Var() yields a runtime error.

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.