I need to access data in nested collections and arrays

:bullseye: What is your goal?

Extract the price, title and name of certain scraped products from Google that are nested in an array with nested collections and arrays.

:thinking: What is the problem & what have you tried?

I tried to use combinations of get and map functions. I think I am on the right track but haven’t found the combination yet (or I am completely on the wrong track).

I have the same problem with a simpler nested array of collections, which I will upload as well.

:clipboard: Error messages or input/output bundles

I will provide an example of the output bundles of the array aggregators. My goal is to map the yellow marked fields in a Google Sheets.

:camera_with_flash: Screenshots (scenario flow, module settings, errors)

1 Like

Hey there,

you do need the get(map()) combo to find it yeah. But since its two arrays, you will need to stack it.

Can you share the complete JSON you are trying to find the data in and we can help build the exact formula?

Hi, Thanks for your fast response.

This is the JSON:
[
{
ā€œarrayā€: [
{
ā€œbacklink_checkā€: {
ā€œdomainRatingā€: 44,
ā€œbacklinksā€: 3322,
ā€œrefdomainsā€: 1002,
ā€œdofollowBacklinksā€: 100,
ā€œdofollowRefdomainsā€: 100,
ā€œurlRatingā€: 9,
ā€œahrefsRankā€: 1070008
}
},
{
ā€œbacklink_checkā€: {
ā€œdomainRatingā€: 92,
ā€œbacklinksā€: 0,
ā€œrefdomainsā€: 0,
ā€œdofollowBacklinksā€: 0,
ā€œdofollowRefdomainsā€: 0,
ā€œurlRatingā€: 0,
ā€œahrefsRankā€: 400
}
},
{
ā€œbacklink_checkā€: null
},
{
ā€œbacklink_checkā€: {
ā€œdomainRatingā€: 1.1,
ā€œbacklinksā€: 25,
ā€œrefdomainsā€: 8,
ā€œdofollowBacklinksā€: 72,
ā€œdofollowRefdomainsā€: 13,
ā€œurlRatingā€: 5,
ā€œahrefsRankā€: 50921934
}
},
{
ā€œbacklink_checkā€: {
ā€œdomainRatingā€: 67,
ā€œbacklinksā€: 1,
ā€œrefdomainsā€: 1,
ā€œdofollowBacklinksā€: 100,
ā€œdofollowRefdomainsā€: 100,
ā€œurlRatingā€: 4,
ā€œahrefsRankā€: 141093
}
},
{
ā€œbacklink_checkā€: null
},
{
ā€œbacklink_checkā€: {
ā€œdomainRatingā€: 34,
ā€œbacklinksā€: 0,
ā€œrefdomainsā€: 0,
ā€œdofollowBacklinksā€: 0,
ā€œdofollowRefdomainsā€: 0,
ā€œurlRatingā€: 4,
ā€œahrefsRankā€: 2614111
}
},
{
ā€œbacklink_checkā€: {
ā€œdomainRatingā€: 26,
ā€œbacklinksā€: 0,
ā€œrefdomainsā€: 0,
ā€œdofollowBacklinksā€: 0,
ā€œdofollowRefdomainsā€: 0,
ā€œurlRatingā€: 0,
ā€œahrefsRankā€: 5585036
}
}
],
ā€œ_IMTAGGLENGTH_ā€: 8
}
]

1 Like

This is my current setup btw, It fills the google sheets with N/A

2 Likes

Ok but do you need all of them or only specific ones? Cause it looks like its an array of similar collections.

Hi, Yes so it’s usually an array of length 5-10 (depending on how many products are found). Then in every collection inside the array, the data structure is the same. Like this in the picture:

1 Like

And what are you trying to do with the data? Send it all together somewhere or do something with each different entry?

I want to upload it all in Google Sheets:

You can see all the N/A’s are because the combination of get() and map() that I currently use returns an empty array probably. I need them filled for all products (8 in this case), but like I said, the range is 5-10 products, so once I have the correct formula, I just copy paste it in the Google Sheets ā€˜Update a Row’ module and replace the number in the get() function with the number of the product

1 Like

But you want each item in a new row no? get(map()) is meant to be used when you need to find specific items from the array. Here it sounds like you just need to process all of them. So use an iterator instead and create a new row in the sheet for each item.

1 Like

No, they are all in the same row for certain keywords. But I think I already found the solution, I will show when I’m done

1 Like

Hi @jeroenvanderwielen ,

To add the fields to the Google Sheet in your case, the recommended approach is to use the bulk add row method. This allows you to insert multiple rows at once efficiently, instead of mapping fields one by one.

I have prepared a sample scenario based on your target setup and am attaching it here. It demonstrates how to structure the data, map the fields, and execute the bulk addition. Please review it carefully and try running it with your data.
[COMMUNITY] -TEST.blueprint(4).json (10.8 KB)

If you encounter any issues, whether with field mapping, scenario execution, or data formatting, please don’t hesitate to reach out. I’ll be happy to guide you through any challenges and ensure it works smoothly.

Looking forward to your feedback!

Best regards,
Msquare Automation
Platinum Partner of Make
@Msquare_Automation

1 Like

Ok you only need map() then to create a primitive array of each value. Then use join() on top of it to create a comma separated list.

1 Like

So getting back: I’ve figured out how to do it. In this case, get(get(map({{array}};backlink_check);1);domainRating) = 44,

get(get(map({{array}};backlink_check);2);domainRating) = 92. And so on…

I found out there are multiple ways to do so, for example:
get(get(get({{array}};1);backlink_check);domainRating) also would return 44 as output here.

The problem for now is thus solved, but a question remains when I only want to get the domainRating where refdomains = 30 for example. This would be easily done with map, but since there are collections here, it is a little but different.