jsonDecode()
The function jsonDecode() decodes a JSON encoded string variable.
Synopsis
<any type> jsonDecode(string json);
Parameters
| Parameter | Description |
|---|---|
| json | The string that is decoded. The variable was encoded by using the
function jsonEncode().
Note:
The Byte-Order-Mark (BOM) is not
processed but causes an error if it is contained in a string.
See also the encoding parameters of the function fileToString(). |
Return Value
Decoded value
Details
JSON is a data exchange format and uses human-readable text for transmitting data objects. JSON builds two structures:
- Name/value pairs. In different languages this is implemented as an object (object), a set (record), a structure (struct), a dictionary or a directory (dictionary), a hash table (hash table), a key list (keyed list) or as an associative array (associative array).
- An ordered list of values. In most languages it is implemented as an array, a vector or a list.
It is largely used instead of XML. Furthermore, it is used for asynchronous browser/server communication (AJAX).
The JSON text format is independent of programming languages and is therefore ideally suited for data exchange.
There are, however some exceptions:
- atime -> object with elements:time, count, dpid
- errClass -> object with elements: prio, type, id, text
- langString -> object with one element per language
- nullptr -> object with the JSON value of null
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
For an example see https://github.com/winccoa/javascript-examples/blob/382351cddd531cddbb689ce9a9c8238096a43103/weather-info/panels/weatherDetails.pnl#L18.
Assignment
Availability
UI, CTRL