4D v16.3JSON Parse |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v16.3
JSON Parse
JSON Parse
The JSON Parse command parses the contents of a JSON-formatted string and extracts values that you can store in a 4D field or variable. This command deserializes JSON data; it performs the opposite action of the JSON Stringify command. In jsonString, pass the JSON-formatted string whose contents you want to parse. This string must be formatted correctly, otherwise a parsing error is generated. JSON Parse can therefore be used to validate JSON strings. Note: If you use pointers, you must call the JSON Stringify command before calling JSON Parse. By default, if you omit the type parameter, 4D attempts to convert the value obtained into the type of the variable or field used to store the results (if one is defined). Otherwise, 4D attempts to infer its type. You can also force the type interpretation by passing the type parameter: pass one of the following constants, available in the Field and Variable Types theme:
Notes:
Examples of simple conversions: C_REAL($r) Example of converting date type data: $test:=JSON Parse("\"1990-12-25T12:00:00Z\"") This example shows the combined use of the JSON Stringify and JSON Parse commands: C_TEXT($JSONContact)
See also
|
PROPERTIES
Product: 4D HISTORY
Created: 4D v14 TAGS JSON validator ARTICLE USAGE
4D Language Reference ( 4D v16) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||