Adding Data within Scenario

I achieved a solution, but I find it very complicated. If there is any better way to do it, I would be happy for advice:
I have this data structure out of a API:

[{ "a":"value1", "b":"value3, "parties":[{ "email":"", "name":"david smith" },{ "email":"", "name":"Martha Smith" }] }]

This data is going to be saved in a table. I need to add one field called “typ”. The content of the field is “apple” in case one of the domains ends on “”. If not it should be “pear”:
for example:

[{ "a":"value1", "b":"value3, "participants":[{ "email":"", "name":"david smith" },{ "email":"", "name":"Martha Smith" }], "typ":"apple" }]

To achieve this I added the two modules “Create JSON” and “Parse JSON”.

In the field “typ” of the “create JSON” module, I’ve included this function:
{{if(contains(toString(map(7.participants; "email")); ""); "apple"; "pear")}}

It looks way to complicated to me, however, as a beginner, I did not find a easier way to achieve this.

Welcome to the Make community!

Yes, that is possible. You’ll need just one module:



Give it a go and let us know if you have any issues!


Thanks, I think I found a more elegant solution by using the “set multiple variables” module. It does not get incorporated in the JSON directly, however I can use the value later on. – still learning.

1 Like