PJROCT – Parse JSON string (real output)
Block SymbolLicensing group: STANDARD
Function Description
The PJROCT block parses input JSON string jtxt according to specified name* parameters
when the input RUN is on. Output signals are real type. In case of an error, the y* outputs are
set to the value of the yerr parameter (e.g. the specified object does not exist or the value is
not a number).
This block expects text in JSON format on the jtxt input. The outputs of y1 to y7 then have the values (string) of the objects identified by the parameters name1 to name7. If one of the parameters name1 to name7 is empty, the corresponding output will be empty and this is not considered as an error. The input string evaluates only if RUN = on. An error is indicated on the output iE. The following cases may occur:
- 0 - no error
- -1 - one of the parameters name1 to name7 refers to an object that does not appear in the input text (at the input jtxt)
- -103 - the text on the input jtxt does not correspond to the JSON format
- -106 - all of the parameters name1 to name7 refer to an object that does not appear in the input text (on the input jtxt)
Examples
Let
jtxt = "{"id": 12345, "params": {"temperature": 23, "pressure": 2.34 },
"description": "reactor1", "values" :[12, 34.5 , 45.0, 30.2]}"
name1 = "params.temperature",
name2 = "values[0]",
name3 = "pressure",
name4 = "description",
then the output y1 will be the "23" string, the output y2 will be the "12" string, output y3
will remain empty and an error will be signaled, the output y4 will remain empty and an error
will be signaled.
This block does not propagate the signal quality. More information can be found in the 1.4 section.
Input
jtxt | JSON formated string | String |
RUN | Enable execution | Bool |
Parameter
name1..name8 | Name of JSON object | String |
nmax | Allocated size of string 0 65520 | Long (I32) |
yerr | Substitute value for an error case | Double (F64) |
Output
y1..y8 | Block output signal | Double (F64) |
iE | Error code | Error |
[Previous] [Back to top] [Up] [Next]
2024 © REX Controls s.r.o., www.rexygen.com