PJROCT – Parse JSON string (real output)
Block SymbolLicensing group: STANDARD
Function Description
Parses input JSON string jtxt according to specified name* parameters when the input
RUN is on. Output signals are real type. Value of the yerr parameter is put on the
y* output when error occured (e.g. specified object is not exist or 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)
Example: 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.
Inputs
jtxt | JSON formated string | String |
RUN | Enable execution | Bool |
Parameters
name1..8 | Property name of JSON element | String |
nmax | Allocated size of string [bytes] 0 65520 | Long (I32) |
yerr | Substitute value for an error case | Double (F64) |
Outputs
y1..8 | Block output signal | Double (F64) |
iE | Error code | Error |
[Previous] [Back to top] [Up] [Next]
2023 © REX Controls s.r.o., www.rexygen.com