What is the correct way to iterate through a json list?

Hello,

I have as output from a python script a list of dictionaries formatted as json.
In each dictionary I have personal information like name and email.
I would like to turn each item in that list into a row, so that the email step is executed for each item separately.
I thought of using JavaScript for that. I can display an alert for each item on this list, but how do I send each item separately to the output?
Is there any other way to do this?

The workflow:
Workflow

Python Script:

import json

dict_list = [
    {
        "name": "Jon Doe",
        "email": "jon_doe@test.com"
    },
    {
        "name": "Jane Doe",
        "email": "jane_doe@test.com"
    }
]

dict_list = json.dumps(dict_list)

Java Script:

var parsedInput = JSON.parse(dict_list);

parsedInput.forEach(function(item) {
  Alert(JSON.stringify(item));
});

Thanks,

Israel

1 Like

Please go through the following video

It explains how to use JSON input step. Use “Source is from a previous step” and pass the JSON String. If you configure JSON input step properly, you will get “Name” and “Email” as two fields to work on.

4 Likes

Thanks Sachin, it worked like a charm!

I do not see link to any video here. Think you can re-post one please.
I have a similar requirement as OP, just that input JSON array has no fixed size and I want to calculate the size of array & then fetch the values at each indexes one by one, while iterating within a loop.

1 Like

Hi! Sudhanshu,

Here is a video URL showcasing the Json Input step -

1 Like