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
Description
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.
Since JSON only understands numeric and string data types, most of the WinCC OAdata types are converted to strings.
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
A data type of time is always encoded in ISO-8601 format in UTC timezone, according to:
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
Assignment
Misc. functions
Availability
UI, CTRL