Creating a custom json payload easily that's easy to maintain

Hello all, I have a feeling I overcomplicated this for myself so I will spare you the details of what I have tried and go to basics…

I have a custom module that parses an HTML to output a collection with two arrays and a number of strings.

The output is:

[
{
“sender”: “John Sender”,
“senderEmail”: “jsender@example.com”,
“recipient”: “James Recipient”,
“orderName”: “My Order Name - Amazing Product Model 001”,
“dueDate”: “09/22/2025”,
“region”: “EMEA”,
“productLine”: “Amazing Products Basic Line”,
“targetLanguages”: [
“Croatian hr_HR”
],
“assetsSpecifications”: “No”,
“instructions”: “No”,
“videoSpec”: null,
“assetsShared”: [
“AmazingProd_Combo_705_Auto_Cleaning_White_Sell_Sheet_EMEA_X185240.pdf”,
“AmazingProd_Supreme_705_Combo_AutoCleaning_OnProduct_Graphic_Merchandising_White.pdf”,
“AmazingProd_Supreme_705_Combo_AutoCleaning_White_Caption_4Stage_4000x4000.psd”,
“AmazingProd_Supreme_705_Combo_AutoCleaning_White_Hotspot_Amazon_Desktop_1464x600.psd”,
“AmazingProd_Supreme_705_Combo_AutoCleaning_White_Photo_InSitu_Caption_Suction_4000x4000.psd”,
“AmazingProd_Supreme_705_Combo_AutoCleaning_White_Photo_InSitu_DockSummary_Caption_4000x4000.psd”,
“AmazingProd_Supreme_705_Combo_AutoCleaning_White_Photo_InSitu_Exclusive mop cover_Caption_4000x4000.psd”,
“AmazingProd_Supreme_705_Combo_AutoCleaning_White_Photo_InSitu_HeatedMopping_SmartScrub_Caption_4000x4000.psd”,
“AmazingProd_Supreme_705_Combo_AutoCleaning_White_Photo_InSitu_LiDAR_Caption_4000x4000.psd”,
“AmazingProd_Supreme_705_Combo_AutoCleaning_White_Photo_InSitu_PrecisionVision_Caption_4000x4000.psd”,
“AmazingProd_Supreme_705_Combo_AutoCleaning_White_ProductOverview.mp4”
]
}
]

I need to pass some of this data into a custom app, which is making an HTTP call and among other things in the body needs to pass a section called customFields that will take a json structure of type:

"customFields": \[

    {"key": "Asset_Delivery_Specifications_yihatv",

    "value": "No"},

    {"key": "Asset_Names_xh7jvt",

    "value":"AmazingProd_Combo_705_Auto_Cleaning_White_Sell_Sheet_EMEA_X185240.pdf, AmazingProd_Supreme_705_Combo_AutoCleaning_OnProduct_Graphic_Merchandising_White.pdf, etc…"},

…..

    \],

The keys in this json structure could change, so I would ideally like to have a module where they are defined and set up and I would also like to define which data from the collection goes with which key.

At the end, I would just like to add this to the payload of the API call, but I cannot fully figure out the best way of doing that

Hey Rastko,

you can use a Create a JSON module and define your own structure in it.

One step further for easier management is to have a Set Variables module first and map that in the Create JSON, then all you need to update is the variables inside the first module.

Thank you, Stoyan, that was indeed my first idea, but, I am sure due to lack of knowledge I don’t get what I expect.

If I set multiple variables and put in some data for them:

Then for the create json module, I would only get the content of these variables, but I need both the name and the value put into json: the name would be the key and the value would be it’s value.

My last idea is to just compose a string and turn that into a json

I managed to resolve my issue by adapting the custom app accepting the data by defining the customFields array input data as an array with key/value pairs.

This thread however helped me quite a bit investigating what I was trying to achieve: How to create a key-value object/collection, and add to an associative array containing key-value pairs

2 Likes