Delete specific JSON keys

Hello, I’m kind of getting sloppy and I need your help. Normally I would figure this out but I have been working way too much…

• I have a JSON string from a webflow module see screenshot 1:
vivaldi_JErG3FgAoc

• I then convert this string to a JSON (not even sure if this is the right approach) see screenshot 2 :
vivaldi_J2hb1NM74d

What I want to achieve is to check for each json key (exemple: 2023-12-04 and 2023-12-08 etc) if those dates have already passed. If so I want to delete them. If not I want to keep them

So if you refer to screenshot 1. 2023-12-04 has passed. I want to delete all of this → “2023-12-04”: [“6h à 7h”, “23h à 0h”],

Thus, what needs to remain is this in this specific format: {“2023-12-08”: [“6h à 7h”, “23h à 0h”],“2023-12-09”: [“7h à 8h”, “9h à 10h”, “10h à 11h”], “2023-12-10”: [“9h à 10h”, “10h à 11h”], “2023-12-13”: [“0h à 1h”, “1h à 2h”, “2h à 3h”, “3h à 4h”, “4h à 5h”, “5h à 6h”, “6h à 7h”, “7h à 8h”, “8h à 9h”, “9h à 10h”, “10h à 11h”, “11h à 12h”, “12h à 13h”, “13h à 14h”, “14h à 15h”, “15h à 16h”, “16h à 17h”, “17h à 18h”, “18h à 19h”, “19h à 20h”, “20h à 21h”, “21h à 22h”, “22h à 23h”, “23h à 0h”]}

Thank you very much!

Hi @olmeria

AS you mentioned this, I understand you need to first search the value in the destination you want to upload then make two routes one for value found and one for value not found.

If you require additional assistance, please don’t hesitate to reach out to us.
MSquare Support
Visit us here
Youtube Channel

1 Like

I thought about using route but I’m not quite sure.

Don’t I need to use an iterator to go through all the date with a formula like if (json key is older than NOW; delete it if not do nothing.

Thank you for the reply.

Ofcourse @olmeria

This can be possible as I see! Please share the screenshot of the data inside these arrays or share the data so you will get the solution.

Or if you need further assistance, please don’t hesitate to reach out to us.
MSquare Support
Visit us here
Youtube Channel

{
“2023-12-08”: [“6h à 7h”, “23h à 0h”],
“2023-12-09”: [“7h à 8h”, “9h à 10h”, “10h à 11h”],
“2023-12-10”: [“9h à 10h”, “10h à 11h”],
“2023-12-13”: [“0h à 1h”, “1h à 2h”, “2h à 3h”, “3h à 4h”, “4h à 5h”, “5h à 6h”, “6h à 7h”, “7h à 8h”, “8h à 9h”, “9h à 10h”, “10h à 11h”, “11h à 12h”, “12h à 13h”, “13h à 14h”, “14h à 15h”, “15h à 16h”, “16h à 17h”, “17h à 18h”, “18h à 19h”, “19h à 20h”, “20h à 21h”, “21h à 22h”, “22h à 23h”, “23h à 0h”]

}

This is an exemple of a json that I got. What is inside “[” and “]” is not relevant right now.

What’s important are values in bold. I want to delete those values based if the date has passed.

This is what I got so far

Don’t how to select all the values for the json. This is an exemple I have multiple json. Ones with 100 dates like those in bold.

Thanks

You’ll need 5 modules for this

1. Parse JSON with variable wrapper

{"dates": {{`JSON string`}}}

2. Convert JSON to array

3. Iterate array, add filter to allow newer dates

4. Aggregate filtered results

5. Convert back to collection (if needed)

3 Likes

Wow. Thank you very much. Straight forward and precise.

Last thing, what if I need to parse the json to a webflow module (it can be a variable for the exemple). I would need to end up with this specific text to parse to the webflow module:

{
“2023-12-08”: [“6h à 7h”, “23h à 0h”],
“2023-12-09”: [“7h à 8h”, “9h à 10h”, “10h à 11h”],
“2023-12-10”: [“9h à 10h”, “10h à 11h”],
“2023-12-13”: [“0h à 1h”, “1h à 2h”, “2h à 3h”, “3h à 4h”, “4h à 5h”, “5h à 6h”, “6h à 7h”, “7h à 8h”, “8h à 9h”, “9h à 10h”, “10h à 11h”, “11h à 12h”, “12h à 13h”, “13h à 14h”, “14h à 15h”, “15h à 16h”, “16h à 17h”, “17h à 18h”, “18h à 19h”, “19h à 20h”, “20h à 21h”, “21h à 22h”, “22h à 23h”, “23h à 0h”]

}

How did you end up with that much knowledge? What’s the best way to train myself? Any recommendation?

Thanks again!

EDIT: managed to do it with a simple parse json thanks again

1 Like

No problem, glad I could help!

If you want to learn more about Make, you can read up in the Help Center. I also recommend doing the tutorials in the Make Academy, and learn advanced skills like how to make custom apps to any API in the Make Partner Training Portal - both have certificates for successful completion.

I just realised you can delete the second step and just do toArray(collection) directly in the Iterator array input.

2 Likes