Close popover
Stephen Stone (StephenS9927)
Anthem Inc

Anthem Inc
StephenS9927 Member since 2019 7 posts
Anthem Inc
Posted: February 21, 2020
Last activity: February 21, 2020

Pega Robotics Parsing JSON with Multidimensional Arrays

Hi. I am developing a process in Pega Robotics Studio 8.0.2033.0 (version 14.0).  I need to accept a json that contains multidimensional arrays and I need to parse elements from them to make further decisions.

The code I built (shown in StudioCode.png) contains a forLoop which iterates through an array called "recommendations" which can have a varying amount of elements.  I'm using the index from the loop to refer to each array element by first concatenating a string to use as my key and derive the parsed value, saving it to a variable to be used later.  I am doing this twice.  The first element I'm parsing may be null or empty but the second will never be null or empty (hence my break here).

The third element is itself another array that I need to loop through (forLoop2) to pull a varying amount of data.

Is it possible to avoid the concatenations and feed the index into a key such as "recommendations[i].lineNumber" where i is my index?  I tried this using the OOB GetValueFromJSONByKeys method but it doesn't want to accept input to the key value.

Is there a better way to accomplish what I'm trying to do with different items I could add to the toolbox?  

Lastly, since the second loop has an unknown amount of data elements to obtain, is there a way to dynamically create a variable or do I need to hardcode some number of variables to use later on?

I included a sample json similar to what I'm using as input (stored in richTextBox1).

Pega Robotic Process Automation 8.0 Robotic Process Automation
Moderation Team has archived post,
Close popover This thread is closed to future replies. Content and links will no longer be updated. If you have the same/similar Question, please write a new Question.