Overview Network JSON/XML


With this function block, network devices can be read out that return a JSON object via an HTTP query.





Inputs

TR
Trigger
Optional trigger. The read query is executed on a rising edge. This input can be used as an alternative to the parameter Interval. If the parameter Interval is 0, the query is executed exclusively via this input.



Outputs

WT
Value
Values from JSON object

Parameters

Interval
Query interval. If this parameter is 0, the query is executed exclusively via the input Trigger.
Server Address of the server
Port Port number
HTTP URL
Specification of a URL; the path after the server name is entered, for example "/directory", the entire URL is then formed from "http://" + Server + this parameter.
HTTP user
Optional user
HTTP password
Optional password
Data type Data is in JSON or XML format
Data Data that is output at the outputs.

Type JSON:

The data is defined in the form: "key:key:data". The last entry is the name of the variable, preceded by one or more ranges.

Example: {"status":{"connected":true,"current":22}}

To read out the two parameters connected and current, the following must be defined:

status:connected
status:current

Arrays are not supported directly, but can be specified via several keys:

"meters":[
    {"power":304.13},
    {"power":0.00},
    {"power":0.00}
]

The entries are then:

meters:power
meters:power:power
meters:power:power:power

Type XML:

The data is defined in the form: "<tag1>:<tag2>:id". The last entry is the name of the variable, preceded by one or more ranges.

Example 1: <current><city id="8010" name="Graz"/><country>AT</country></current>

To read out the two parameters city id and name, the following must be defined:

<current>:<city:id
<current>:<city:name

to read out the value of country, the following must be defined:

<current>:<country>


Use error output With this option, in the event of errors the output is set to the value from the parameter "Output on error". For example, if the variable is missing in the JSON string, this value is output at the output. In the case of general errors, e.g. when the server is unreachable, only the first output is set to this value. The first output can therefore be used as an error output.
Output on error Value that is output at the output in the event of an error.






See also common parameters of all function blocks.