Clean up double brackets for JSON parse

I get the output from an API with double brackets “[[” at the start of the data and “]]” at the end of the data

Which means when trying to parse Json , the result isn’t an actual json because it doesn’t recognise the format (even if I have put the right format in place).
CleanShot 2022-09-16 at 10.26.12

I need to iterate these into a proper JSON so I get multiple bundles to then make iterationsto send the data back into google sheet lines.

The problem starts with the “[[” which makes it a double quoted json rather than simple , I think. So it makes it really hard to work with the data. But couldn’t clean it with replace() function or node.

Any suggestion?

Thanks!

Just use an iterator tool and you’ll get bundles.

1 Like

Thanks Alex! But to my point it doesn’t… wherever I put it before or after json it just won’t…

CleanShot 2022-09-16 at 18.12.11

CleanShot 2022-09-16 at 18.14.03

Use the iterator tool in the green tools. Iterate the output array and you’ll get bundles.

Or book a call with us. We are a 4-year old Make.com partner. We offer a one hour video call where we explain and show how Make can help your organization. We even build some scenarios and share them with you so get more value than a usual exploratory discussion. Book some time with me at Make.com Hero - NewPath Consulting I look forward to talking to you and your team should they join us.

1 Like

Hi @vince,

Can you show us your iterator set up?

Loic

1 Like

You can see here the iterator doesn’t understand the bundle piece.
CleanShot 2022-09-18 at 18.35.37

Here’s some approaches I had with iterators/agg
CleanShot 2022-09-18 at 18.33.54

Same thing…
By the way this is using the specific Hugging Face inference API call
https://api-inference.huggingface.co/models/arpanghoshal/EmoRoBERTa
More doc info on this: 🤗 Accelerated Inference API

I usually don’t have any problem with the output of these APIs.

Thanks guys!
Vince

Hi @vince,

Try to parse the response in your HTML module:

image

Then try the iterator with the array from the parsed response.

Actually, the easiest is probably to use the replace function. So you set up your parse JSON module like that:

image

This should do the trick

Hi Loic, thanks for getting back! These were exactly the options I tried at the start, which I would have expected to work as per my initial question… but neither work for some reason, which is the weirdest thing.

Here’s the JSON replace response error

Heres the output you get when Parsing via the HTTP, which is even worse than not parsing :slight_smile:

Any thoughts? :thinking:

That’s perfect output from the iterator from the http module. Just send the Data array output of the http module to the iterator and you’ll get a bundle per collection.

Hi @vince, try to use the function toString({{data}}) before to perform the replace.

@alex.newpath the issue with this payload is that the array does not have a name so the iterator does not give a workable output. I was able to reproduce Vince issue.

3 Likes

Thanks Loic it worked! Perfect! I did forget about this toString() function… That’s what I needed to be able to work with the raw data! And indeed using replacement of [[ to replace and clean this, it’s then recognized as perfect JSON!

Thanks Loic
Vince

1 Like

Oh I didn’t notice that. I thought data was the array. Good eye. Bad api design.