Function Var2Json() Foundation
Converts an array or object to JSON text.
Var2Json( <aoValue> ) -> cJson
A character string with the JSON text in UTF-8 encoding.
The function Var2JSon() can handle nested values, such as an array of objects with their members which in turn may also be arrays or objects. However, Var2JSon() cannot detect circular references. For example, passing in an object which references itself in one of its members is not supported.
JSON supports only array and object as the root data type. Therefore, passing a scalar value such as a string in <aoValue> is not supported. However, object members and array elements may contain values of any Xbase++ (including scalar) data type.
|Data Type||Representation in cJson|
|Array||Ordered list of values|
|Character||JSON string literal, see JsonEncode()|
|Codeblock||Expression as JSON string|
|Date||ISO 8601 date value as recommended by JSON schema|
|Logical||JSON literal true / false|
|Numeric||Numeric with optional minus sign, fraction and/or exponent part. Precision is equivalent to Xbase++ numeric type.|
|Object||Collection of name/value pairs|
|Undefined||JSON literal null|
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.