PJSOCT – Parse JSON string (string output)

Block SymbolLicensing group: STANDARD
PIC

Function Description
Parses input JSON string jtxt according to specified name* parameters when the input RUN is on. Output signals are string type.

This block expects text in JSON format on the jtxt input. The outputs of sy1 to sy7 then have the values 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 sy1 will be the "23" string, the output sy2 will be the "12" string, output sy3 will remain empty and an error will be signaled, the output sy4 will be the "reactor1" string.

Inputs

jtxt

JSON formated string

String

RUN

Enable execution

Bool

Parameters

name1..8

Name of JSON object

String

nmax

Allocated size of string [bytes]   0  65520

Long (I32)

Outputs

sy1..8

String output value

String

iE

Error code

Error

2023 © REX Controls s.r.o., www.rexygen.com