cancel
Showing results for 
Search instead for 
Did you mean: 

Collection in collection

NickiKristensen
Level 4
Hi,

We have a process that returns a JSON response, without any problems. The response consists of an itinerary for public transport, ie. take bus number 84 to the train station, and take the train to the next train station.
The parameters (Triplist, Trip and Leg) are defined in the Web API - the first two collections are returned fine to the process, but the last parameter Leg is always empty, although the raw text response contains a value
31251.png
Is it a limit in Blue Prism that collection can not be in a collection, in a collection?

When I open the Trip collection, the values look like this:
31252.png


------------------------------
Nicki Kristensen
RPA Developer
IBC International Business College
------------------------------
1 BEST ANSWER

Helpful Answers

Simple way could be something like:
Create empty collection Leg_all
Loop TripList(
 Loop TripList.Trip(
  Merge rows (TripList.Trip.Leg into Leg_all)
 )
)


------------------------------
Andrey Kudinov
Project Manager
MobileTelesystems PJSC
Europe/Moscow
------------------------------

View answer in original post

8 REPLIES 8

AndreyKudinov
Level 10
Afaik Blueprism has no limitations on nested collections, there must be another reason. 
Json example would help. Could web api limitation.

------------------------------
Andrey Kudinov
Project Manager
MobileTelesystems PJSC
Europe/Moscow
------------------------------

Hi Andrey,

I quick example of the output is here:

{
"TripList":{
  "noNamespaceSchemaLocation":"http://xmlopen.rejseplanen.dk/xml/rest/hafasRestTrip.xsd",
  "Trip":[{
    "Leg":[{
      "name":"til fods",
      "type":"WALK",
      "Origin":{
        "name":"Fra",
        "type":"ADR",
        "time":"06:14",
        "date":"10.10.19"
        },
      "Destination":{
        "name":"<Train Station>",
        "type":"ST",
        "time":"06:21",
        "date":"10.10.19"
        },
      "Notes":{
        "text":"Varighed: 7 min.;(Afstand: ca. 0,4 km);"
        }
      }]
    }]
  }
}

Could it be due to the fact that Blue Prism sees more than one Leg collection in the Trip collection as shown in the second screenshot? 


------------------------------
Nicki Kristensen
RPA Developer
IBC International Business College
------------------------------

Actual TripList and Trip contains all the data, as you say. And I guess you are right that blueprism web api just can't handle sub-sub-collections. I guess you can ask support why.

I didn't get to use Web api properly so far, because it had some issues with proxy authentification when I tested it and our prod is still 6.2.1 (blueprism cant fix their log migration scripts). It could be a nice feature for new users, but HttpWebRequests + json/xml parsing are more flexible in the end and I'm not sure we are going to migrate old stuff to web api anyway. 

Abstractions are nice until they are getting in the way. As an example, issues 6000 queries to database, doing some checks on them and combining to a single collection is about 10 times faster in a code stage compared to 'blueprism way'. Collection manipulations and calculations are slow.

------------------------------
Andrey Kudinov
Project Manager
MobileTelesystems PJSC
Europe/Moscow
------------------------------

Check blueprism documentation:

https://portal.blueprism.com/system/files/documents/v6.4%20User%20Guide%20-%20Web%20APIs_2.pdf

page 25/26 

So you can extract the output

------------------------------
Cemile Demirci
Robotics Proces Developer
Alliander
Europe/London
------------------------------

@CemileDemirci I figured it out later. Both {"TripList":[{"Trip":[{"Leg":[{"name":"test value",}]}]}]} and {"TripList":{"Trip":[{"Leg":[{"name":"test value",}]}]}} are deserialized in the same way, but treated differently in terms of json path in web api.
Similar inconsistency exists in json vbo - if you serialize and deserialize nested collection (several times for extra effect), you get different result. I had to fix it as it was annoying.

@NickiKristensen $.TripList.Trip..Leg should work with your example, but only until you have two+ trips/legs.
You can still use a parent TripList to get all the data.

------------------------------
Andrey Kudinov
Project Manager
MobileTelesystems PJSC
Europe/Moscow
------------------------------

Hi @AndreyKudinov -​ I tried your tip with $.TripList.Trip..Leg, but as you say, I'm limited to 2+ legs.

I get the data from the TripList, but how would I extract the data "manually", ie. get the Leg-data into a collection?



------------------------------
Nicki Kristensen
RPA Developer
IBC International Business College
------------------------------

Simple way could be something like:
Create empty collection Leg_all
Loop TripList(
 Loop TripList.Trip(
  Merge rows (TripList.Trip.Leg into Leg_all)
 )
)


------------------------------
Andrey Kudinov
Project Manager
MobileTelesystems PJSC
Europe/Moscow
------------------------------

Thanks, Andrey - that did the trick!

------------------------------
Nicki Kristensen
RPA Developer
IBC International Business College
------------------------------