Last activity: 21 Feb 2020 14:12 EST
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).