Merging bundles of key-value pairs

I need to merge multiple bundles of key value pairs into one bundle.

So far I can produce separate bundles which contain one key-value pair:

[
    {
        "Would you like to receive our news letter?": "Yes"
    }
]

and I think I need to have the following so I can map the values later in another module.

{
    "Would you like to receive our newsletter?": "Yes",
    "Another question?": "No",
    "Third question?": "Yes"
}

How can I get these key value pairs created so I can then map the values into subsequent modules?

Cheers for your help

1 Like

Hi,
You can use a text aggregator to merge them first. Then, in the module where you need to map the JSON, add the opening and closing brackets around your aggregated data
Hope this helps!
Cheers,
Harsh

2 Likes

Thanks, that sounds promising. I’ll give it a go.

1 Like

Hi. So I think I’ve done that now but I’m not sure how it helps me.

As shown previously, this is where I think I need to get to:

{
    "Would you like to receive our newsletter?": "Yes",
    "Another question?": "No",
    "Third question?": "Yes"
}

Now as a result of the text aggregation I have

[
    {
        "text": "{\"Would you like to receive our news letter?\":\"Yes\"},{\"Select your customer group\":\"Individual crafter/artist\"},{\"Post Code (first 3 letters)\":\"LA96LF\"},{\"First Name\":\"Emily\"},{\"Do you agree to the Scrapstore T&Cs?\":\"No\"},{\"How many Children will benefit from your Scrap?\":\"2\"},{\"How many adults will benefit from your scrap?\":\"2\"},{\"Org / School name (if applicable)\":\"Castle Park\"},{\"Gender\":\"Female\"}",
        "__IMTKEY__": "7DH7344RAMMN8EJ63ZR8DRQM80"
    }
]

How does this help me when I need to map the individual values to a new module?

For instance, if I want to extract the ‘would you like to receive our newsletter’ answer (yes) and map it to this following screenshot, how do I do that with what has been generated from this text aggregator?

I think one important factor to reitterate is that I don’t know if all 9 bundles will be received and I don’t know what order they’ll be received in so cannot rely on using an array and indexing that array with the value of an iterator.

Sorry if this is a basic fix but I’m afraid I don’t understand how to get the values I need from this.

1 Like

@AlT
Hi, I am not sure if this is the optimal solution, but I may be able to offer a solution.

It would be possible to pass the text combined by Text Aggregator to Text Parser’s Replacemodule, remove the { and }, and then use the Parse JSONmodule to map the values.

RegExp: [{}]

Data Structure is not always necessary.