Accessing value from a second iterator

Hello,

I have a JSON file with this format:

{
  "Place": {
    "Name": "Louvre Museum",
    "Google_place_id": "",
    "City": "Paris",
    "Region": "Ile-de-France",
    "Country": "France",
    "Cultural_type": "Museum",
    "Facts": {
      "Historical_facts": [
        "Originally built as a medieval fortress by King Philip II in the late 12th century.",
        "Transformed into a royal palace by Francis I in the 16th century.",
        "Officially became a public museum during the French Revolution in 1793.",
        "Home to Napoleon Bonaparte’s extensive art collections during his rule.",
        "Expanded significantly in the 19th century under Napoleon III.",
        "The Louvre Pyramid entrance was inaugurated in 1989, designed by architect I. M. Pei."
      ],
      "Architectural_facts": [
        "Features medieval fortress foundations still visible in the museum.",
        "Renovated in Renaissance style under Francis I and Henry IV.",
        "Louis XIV expanded the Louvre, adding the classical Colonnade of the east façade.",
        "The Grand Gallery, one of the longest museum halls in the world, spans over 1,200 feet.",
        "The Louvre Pyramid, made of glass and metal, serves as the main entrance.",
        "Incorporates Baroque, Renaissance, and Neoclassical architectural elements.",
        "The Cour Napoléon houses the central glass pyramid entrance structure.",
        "The Richelieu Wing was added in the 19th century to house additional artworks.",
        "The Arc de Triomphe du Carrousel, near the Louvre, was built by Napoleon in 1806.",
        "The underground Carrousel du Louvre shopping area was completed in 1993."
      ],
      "Geographical_facts": [],
      "Historicalfigure_facts": [],
      "Art_facts": [],
      "Political_military_facts": [],
      "Cultural_facts": [],
      "Daily_life_tradition_facts": [],
      "Religious_facts": [],
      "Scientific_facts": [],
      "Mystery_legends_facts": [],
      "Restauration_preservation_facts": [],
      "Community_local_facts": [],
      "Economic_commercial_facts": []
    }
  }
}

I have a collection of Facts, sorted in categories as array, with multiple facts in them
I want to extract each Facts and parse them in airtable.
I think I should use a double iterator to do so - The first one to go through each category and the second to go through each item of the array.

I have this simple scenario with my JSON module

Problem:
I cannot access the value
If I put this value in my first iterator:


Then in my second iterator I don’t see anything despite seeing the bundle in the output of my first iterator:

And if I try to convert my collection to an array, then I can see an item Value in my Second iterator


I can manage to access the data in the array

But I cannot retreive the name of my category, the Key of the object:

And I need both, the value and the key to map correctly in Airtable.

What do I do wrong?
Thanks in advance

Welcome to the Make community!

The “Facts” variable is not an array. You cannot use it directly in an Iterator module.

You still can, just that you have to manually type or paste this in to reference the key variable:

{{13.key}}

Output:

Hope this helps! Let me know if there are any further questions or issues.

Module Export - quick import into your scenario

You can copy and paste this module export into your scenario. This will import the modules (with fields/settings/filters) shown in my screenshots above.

  1. Move your mouse over the line of code below. Copy the JSON by clicking the copy button on the right of the code, which looks like this:

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the editor.

  3. Click on each imported module and re-save it for validation. There may be some errors prompting you to remap some variables and connections.

JSON module export — paste this directly in your scenario

{"subflows":[{"flow":[{"id":232,"module":"json:ParseJSON","version":1,"parameters":{"type":""},"mapper":{"json":"{\n  \"Place\": {\n    \"Name\": \"Louvre Museum\",\n    \"Google_place_id\": \"\",\n    \"City\": \"Paris\",\n    \"Region\": \"Ile-de-France\",\n    \"Country\": \"France\",\n    \"Cultural_type\": \"Museum\",\n    \"Facts\": {\n      \"Historical_facts\": [\n        \"Originally built as a medieval fortress by King Philip II in the late 12th century.\",\n        \"Transformed into a royal palace by Francis I in the 16th century.\",\n        \"Officially became a public museum during the French Revolution in 1793.\",\n        \"Home to Napoleon Bonaparte’s extensive art collections during his rule.\",\n        \"Expanded significantly in the 19th century under Napoleon III.\",\n        \"The Louvre Pyramid entrance was inaugurated in 1989, designed by architect I. M. Pei.\"\n      ],\n      \"Architectural_facts\": [\n        \"Features medieval fortress foundations still visible in the museum.\",\n        \"Renovated in Renaissance style under Francis I and Henry IV.\",\n        \"Louis XIV expanded the Louvre, adding the classical Colonnade of the east façade.\",\n        \"The Grand Gallery, one of the longest museum halls in the world, spans over 1,200 feet.\",\n        \"The Louvre Pyramid, made of glass and metal, serves as the main entrance.\",\n        \"Incorporates Baroque, Renaissance, and Neoclassical architectural elements.\",\n        \"The Cour Napoléon houses the central glass pyramid entrance structure.\",\n        \"The Richelieu Wing was added in the 19th century to house additional artworks.\",\n        \"The Arc de Triomphe du Carrousel, near the Louvre, was built by Napoleon in 1806.\",\n        \"The underground Carrousel du Louvre shopping area was completed in 1993.\"\n      ],\n      \"Geographical_facts\": [],\n      \"Historicalfigure_facts\": [],\n      \"Art_facts\": [],\n      \"Political_military_facts\": [],\n      \"Cultural_facts\": [],\n      \"Daily_life_tradition_facts\": [],\n      \"Religious_facts\": [],\n      \"Scientific_facts\": [],\n      \"Mystery_legends_facts\": [],\n      \"Restauration_preservation_facts\": [],\n      \"Community_local_facts\": [],\n      \"Economic_commercial_facts\": []\n    }\n  }\n}"},"metadata":{"designer":{"x":378,"y":-267},"parameters":[{"name":"type","type":"udt","label":"Data structure"}]}},{"id":233,"module":"builtin:BasicFeeder","version":1,"parameters":{},"mapper":{"array":"{{toArray(232.Place.Facts)}}"},"metadata":{"designer":{"x":678,"y":-267}}},{"id":234,"module":"builtin:BasicFeeder","version":1,"parameters":{},"mapper":{"array":"{{233.value}}"},"metadata":{"designer":{"x":978,"y":-267}}},{"id":235,"module":"util:TextAggregator","version":1,"parameters":{"rowSeparator":"\n","feeder":234},"mapper":{"value":"Fact #{{234.`__IMTINDEX__`}}: \"{{234.value}}\""},"metadata":{"designer":{"x":1278,"y":-267},"parameters":[{"name":"rowSeparator","type":"select","label":"Row separator","validate":{"enum":["\n","\t","other"]}}],"advanced":true},"flags":{"stopIfEmpty":true}},{"id":237,"module":"util:TextAggregator","version":1,"parameters":{"rowSeparator":"\n","feeder":233},"mapper":{"value":"*{{233.key}}*\n{{235.text}}\n-----"},"metadata":{"designer":{"x":1578,"y":-267,"messages":[{"category":"last","severity":"warning","message":"A transformer should not be the last module in the route."}]},"parameters":[{"name":"rowSeparator","type":"select","label":"Row separator","validate":{"enum":["\n","\t","other"]}}],"advanced":true},"flags":{"stopIfEmpty":true}}]}],"metadata":{"version":1}}

Note: Did you know you can reduce the size of blueprints and module export code like the above, using the Make Blueprint Scrubber?

— @samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

Thank you @samliew I was not using the correct syntax for key. It works now.

My first iterator (21) is toArray(Facts) then second iterator (22) is value[] and I catch my variable with a set multiple variable (23):

Key = {{21.key}} → I was trying to use keys()
Value = {{22.value}}

2 Likes

No problem, glad I could help!

1. If anyone has a new question in the future, please start a new thread. This makes it easier for others with the same problem to search for the answers to specific questions, and you are more likely to receive help since newer questions are monitored closely.

2. The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep the Community organized.

This marks the topic as solved, so that:

  • others can save time when catching up with the latest activity here, and
  • allows others to quickly jump to the solution if they come across the same problem

To do this, simply click the checkbox at the bottom of the post that answers your question:
Screenshot_2023-10-04_161049

3. Don’t forget to like and bookmark this topic so you can get back to it easily in future!

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

Getting Started

Help Centre Basics

Articles & Videos

Hope this helps! Let me know if there are any further questions or issues.

— @samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.