Map JSON Array Items to List in Email

In one of my flows, I receive a JSON array as part of an HTTP GET request to a 3rd party API.
I now want to map a specific property within the array of elements to be added to an (HTML) email.

Here is an example

{"employees":[    
    {"name":"Eve", "email":"eve@example.com", "age":23},    
    {"name":"Alice", "email":"alice@example.com", "age":28},
]}

This should be transformed into the following HTML (for an email):

<ul>
  <li>eve@example.com</li>
  <li>alice@example.com</li>
</ul>

What would be the best approach of doing this transformation?

Hey @axgr,

To utilize the data effectively in subsequent steps, you might consider this approach:

1. Start with the HTTP action and choose Return Response.
2. Input your JSON data directly into the response section.
3. Afterwards, reference the parsed output in your Gmail step (or whichever service you’re integrating).

This way, the extracted emails can be easily mapped into the desired HTML format for your email. Hope this helps!

Cheers!

image

Just noticed, the JSON you provided has a slight issue with a trailing comma, making it invalid. Here’s a quick way to automatically correct it in ActivePieces:

1. Use a Text Formatter step with the “Replace” function:

  • Find: },]}
  • Replace with: }]}
    This should clean up any trailing commas.

2. Proceed to use the cleaned JSON in the steps I mentioned earlier.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.