JSON string parsing issue
-
Hello all in REXYGEN!
I have issue with parsing JSON object through PJSOCT block.
The input to the PJSOCT block is string, the output is also suppost to be a string but it is somehow interpretted as number and moreover represented in exp format. This destroyes long integer variables that I receive from communication partner and need to process in REXYGEN executive.In the enclosed example a simple JSON object is parsed with integer id parameter:
{ "status":"success", "id": 456877932143130020 }
but PJSOCT outputs the id parameter as 4.5687793214313e+17
Could you help, please?
Thanks and Regards,
Michal -
@mkrupicka Hello Michal,
thank you for your post. You are right - the behaviour of PJSOCT function block is not as one would expect. However it is also caused by format of "id" item - since the value is written without quotation marks it represents number by the definition.
I would use different approach:
- search the string for substring "id"
- offset the position (I presume that the message structure is given)
- extract substring (I presume that the ID length is given)
If you need any help just let me know.
Kind regards,
Tomas