Dynamic Data Structure


I’m currently integrating data from the Pipedrive module into a HTTP API using JSON. Everything is functioning well, but I’m encountering a challenge with optimizing the data transfer process. The HTTP API accepts JSON, including empty fields without issue. However, it requires that the fields named “@type” must not be empty if included in the payload.

My objective is to exclude the “@type” key entirely when its value is empty, to maintain a cleaner and more efficient code structure. Given the complex JSON structure with multiple objects, using multiple conditional statements (IFs) becomes cumbersome. Here’s an example of the JSON structure I’m working with:

"someObject": {
            "targetID": "ID_XYZ",
            "target": {
                "@type": "TARGETTYPE1",
                "targetValue": 50

I need a solution where if the value for “TARGETTYPE1” is unset, the entire “target” object should not be passed to the HTTP API. Could you suggest a more streamlined approach or code optimization techniques to handle this scenario effectively?


Welcome to the Make community!

You can use the built-in function if and length


{{if(length(1.value) > 0; """@type"": """ + 1.value + ""","; emptystring)}}


samliewrequest private consultation

Join the Make unofficial Discord server!