Source is not valid JSON if key is not present

Hi guys! I’m trying to parse using JSON module using map() to search metaData for entries where “key” is “_sameday_shipping_locker_id” and returning the associated “value” but if “_sameday_shipping_locker_id” isn’t present, I would like the outputs to be “{}” no value.

The JSON module parses the code successfully if “_sameday_shipping_locker_id” is present but if it’s not present it returns “DataError
Source is not valid JSON.”



What am I missing?
Thanks a lot!

You probably forgot to use the get or first function around the map function.

You are currently doing an ifempty directly on an array of values, which is incorrect.

For more information, see Mapping with arrays below.

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

Getting Started

Help Centre Basics

Articles & Videos

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

1 Like

Thanks for the heads-up! :blush: