INSERT_JSON$ (json$, key$, value$) | (only available on Wx100 PLC firmware >= F94.2) |
Purpose | This provides a convenient way to append a key-value pair to an exist JSON object.
(for details please refer to
JSON specifications). This function takes the json-formatted object string json$, a key string key$ and a value string value$ as parameters and returns a new JSON object string with the new key$ and value$ being appended to the last key-value pairs of the original JSON object. If json$ is an empty string, then this function will first create an empty JSON object string "{}" and the key$ and value$ will become the first key-value pair in the newly created JSON object string and returned by this function. |
Examples |
A$ = "" A$ = INSERT_JSON$(A$, "Temperature", "20.5") ' value$ contains a primitive (number) ---(1) B$ = INSERT_JSON$(A$, "DeviceID", "Wx100") ' value$ contains a string literal -------(2) C$ = INSERT_JSON$(B$, "Alarm", "False") ' value$ contains a primitive (boolean)---(3) ' - will convert to lower case D$ = "" D$ = INSERT_JSON$(D$, "Data1", C$) ' value (C$) is a JSON object string |
Comments: |
Result from the above statements:
(1) A$ contains: {"Temperature":20.5}
|
See Also | GET_JSONVAL$()
|