4D v16.3JSON Stringify |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v16.3
JSON Stringify
JSON Stringify
The JSON Stringify command converts the value parameter into a JSON string. This command serializes data into JSON; it performs the opposite action of the JSON Parse command. Pass the data to be serialized in value. It can be expressed in scalar form (string, number, date or time) or by means of a 4D object (or an object array). In the case of an object, you can include all types of values (see the JSON data types paragraph). JSON formatting must respect the following rules:
You can pass the optional * parameter to include formatting characters in the resulting string. This improves the presentation of JSON data (known as pretty formatting). Conversion of scalar values: $vc:=JSON Stringify("Eureka!") // "Eureka!" Conversion of a string containing special characters: $s:=JSON Stringify("{\"name\":\"john\"}") Example using a pointer to a variable: C_OBJECT($MyTestVar) Serialization of a 4D object: C_TEXT($varjsonTextserialized) Examples of serializing a 4D object with and without the * parameter: C_TEXT($MyContact) The advantage of this formatting is clear when the JSON is shown in a Web area:
See also
|
PROPERTIES
Product: 4D HISTORY
Created: 4D v14 ARTICLE USAGE
4D Language Reference ( 4D v16) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||