cancel
Showing results for 
Search instead for 
Did you mean: 

JSON to Collection

ManuelMascia1
Level 2
When I use the action "JSON to collection", it give me a JSON:Array in the collection. How can I handle this JSON:Array?
9 REPLIES 9

SagarMehta
Level 3
I am having similar issue and not sure how to loop through JSON.Array as it says ""Row 1 of 1"" even if I have 4 rows. I would appreciate any suggestions on this

DavidEdwards-Da
Level 5
This occurs when the there is an array in the JSON, for example the following JSON would present a single row collection with JSON:Array: [{""message"": ""Hello World!"", ""fromperson"": ""David"", ""toperson:"" ""manuel""}] To access this, when you call JSON to Collection, move it into a staging collection. From there, use a calc stage to copy [Staging Coll.JSON:Array] into the final collection. In this case, we would wind up with a collection with 3 columns and a single row.

Anonymous
Not applicable
DavidED, I see that this would be helpful for pulling the first record in an array but I cannot access the second or third if there is more than one. Any thoughts there?

DavidEdwards-Da
Level 5
Can you post some example JSON to help explain your issue?

DukeAmes
Level 3
Hey DavidED, Would you mind sharing your solution with a more detailed explanation?  I kind of new to BP programming and your example is not making sense.  After JSON to Collection, I have: Row 1 of 1 Row 1 of 1 Row 1 of 1 ... How do I convert this collection to a collection of rows with columns? Appreciate your support, thanks!

DavidEdwards-Da
Level 5
Post example JSON and I'll give you a hand.

ChristosVasilop
Level 2
Any ideas on this issue? I am facing the same issue after changes on the JSON string I am getting. I m using the vbo (JSON to collection skipping the JArray) but suddenly I am getting  JSON:Array collections.

This is how I got mine to work: let's say your JSON is something like this:
[{""message"": ""Hello World!"", ""fromperson"": ""David"", ""toperson:"" ""manuel""},{""message"": ""Goodbye World!"", ""fromperson"": ""Eric"", ""toperson:"" ""Frank""}]

First, use JSON to Collection. It will come back with a collection that has multiple rows. Each row of this collection is itself another collection (which is why is says something like Row 1 of 1.

Next, we will loop through this collection. This will let us access each row.

Within this loop, use the "Utility - Collection Manipulation" action called "Append Rows to Collection". Your final collection will be the main collection as well as the output. The looped row will be the Collection to Append.
227.jpg

228.jpg


------------------------------
Jordan Bondurant
------------------------------

FWIW - An update to the Utility - JSON VBO was posted to the Digital Exchange yesterday which includes a significant refactoring of the JSON to Collection (Skipping JArray) action. You should not experience situations where you end up with an array of collections anymore - unless that's the way the JSON is actually designed.

Cheers,

------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------