Trouble Parsing Some Weird JSON from a Webhook

Hi,

I have a Webhook set up that is passing the following string example into Make:

[
    {
        "values": "\"{\\\"_6\\\":\\\"My Registration Information Is Incorrect\\\",\\\"_7\\\":\\\"This is the area where the message is composed.\\\\nIt is a multiline text box with test content in it.\\\\n\\\\nI skipped a line and now this is line 4 (but the third line of text).\\\",\\\"_0\\\":\\\"100000\\\",\\\"_1\\\":\\\"Chris\\\",\\\"_2\\\":\\\"Harper\\\",\\\"_3\\\":\\\"Communications\\\",\\\"_4\\\":\\\"Corporate\\\",\\\"_5\\\":\\\”email@gmail.com\\\"}\""
    }
]

My Make scenario can’t seem to figure out how to parse this data into an array or blocks that I can use in the scenario.

I have tried passing through the JSON in the webhook and leaving that off (both ways). I have also tried various text parsers.

I can try writing some regex to capture the data, but I’d prefer not to because I want to easily be able to use this type of scenario in the future, for different data sets, and I don’t want to keep messing with the regex.

I don’t have control over the app that is sending this data, so this format is what I have to deal with.

What I would like to end up with is some kind of array of key:pair values that I can use in subsequent modules.

Any ideas of what I could try?

Welcome to the Make community!

Screenshots as well please.

1. Screenshots of module output bundles

Please share screenshots of the above output bundles in question? It would really help other community members to see what you’re looking at.

You can upload images here using the Upload icon in the text editor:
Screenshot_2023-10-07_111039

2. Scenario blueprint

Please export the scenario blueprint file to allow others to view the mappings and settings. At the bottom of the scenario editor, you can click on the three dots to find the Export Blueprint menu item.

Screenshot_2023-08-24_230826
(Note: Exporting your scenario will not include private information or keys to your connections)

Uploading it here will look like this:

blueprint.json (12.3 KB)

3. And most importantly, Input/Output bundles

Please provide the input and output bundles of the modules by running the scenario (or get from the scenario History tab), then click the white speech bubble on the top-right of each module and select “Download input/output bundles”.
Screenshot_2023-10-06_141025

A.

Save each bundle contents in your text editor as a bundle.txt file, and upload it here into this discussion thread.

Uploading them here will look like this:

module-1-input-bundle.txt (12.3 KB)
module-1-output-bundle.txt (12.3 KB)

B.

If you are unable to upload files on this forum, alternatively you can paste the formatted bundles in this manner:

  • Either add three backticks ``` before and after the code, like this:

    ```
    input/output bundle content goes here
    ```

  • Or use the format code button in the editor:
    Screenshot_2023-10-02_191027

Providing the input/output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

Following these steps will allow others to assist you here. Thanks!

2 Likes

Thanks for the tips, @samliew! Here’s a bit more detail as you suggested:



Here’s a screenshot showing the Webhook output as well as the full output bundle content:

And here’s an export of the blueprint:

blueprint.json (15.0 KB)



I included the output bundle of the Webhook in the first post, but here it is again so it is all in one place:

[
    {
        "values": "\"{\\\"_6\\\":\\\"My Registration Information Is Incorrect\\\",\\\"_7\\\":\\\"This is the area where the message is composed.\\\\nIt is a multiline text box with test content in it.\\\\n\\\\nI skipped a line and now this is line 4 (but the third line of text).\\\",\\\"_0\\\":\\\"100000\\\",\\\"_1\\\":\\\"Chris\\\",\\\"_2\\\":\\\"Harper\\\",\\\"_3\\\":\\\"Communications\\\",\\\"_4\\\":\\\"Corporate\\\",\\\"_5\\\":\\\"Chris.Harper@arborcompany.com\\\"}\""
    }
]



And for reference, here’s the input bundle of the Webhook module, which is blank, but I think that is normal since it is the first step in the scenario:

[]

Looks like you need to put the “value” variable, into a JSON “Parse JSON” module.

However, you need to “unescape” the JSON first.

{{ replace(replace(141.values; "/(^""|""$)/g"; emptystring); "/\\(?=[""n])/g"; emptystring) }}

Output:

Screenshot_2024-02-23_230200

3 Likes

This worked! I had a feeling there was something going on with that JSON and all of the escaped characters, so this was exactly what I needed.

Thank you, @samliew!

2 Likes

No problem, glad I could help.

Welcome again to the Make community and hope you’ll enjoy using Make!

2 Likes