Skip to content
Need assistance wit...
 
Notifications
Clear all

Need assistance with a JSON data structure

3 Posts
2 Users
0 Reactions
5 Views
Zbulo
(@zbulo)
Posts: 13
Active Member
Topic starter
 

Hello Makers, I'm looking to construct a JSON string for an API call using an HTTP module.

I'm currently utilizing a Create JSON module, feeding it fields from preceding steps.

This works fine for basic elements, but I'm having trouble understanding the required data structure for an array field named "accommodation", as shown below.

Here's an example of the desired structure:

"accommodation": [
           {
               "externalId":"HPO1",
               "libraryExternalId":"HOTELS",
               "arrivalDate":"2025-09-05",
               "departureDate":"2025-09-06",
               "comment":"A generous breakfast buffet is included"

           },

 {
               "externalId":"HPO2",
               "libraryExternalId":"HOTELS",
               "arrivalDate":"2025-09-06",
               "departureDate":"2025-09-07",
               "comment":"Dinner is included"

           }
       ],

The input for the accommodation field is a JSON string generated by an Aggregate to JSON module. Here's an example of that input:

[
{"comment":"1x DBL (B&B)","externalId":"recRGrW4ugkbvK8T3","arrivalDate":"2025-05-16","departureDate":"2025-05-17","libraryExternalId":"Hotels"},
{"comment":"1x DBL (B&B)","externalId":"rectZqonA40XLxT2C","arrivalDate":"2025-05-17","departureDate":"2025-05-18","libraryExternalId":"Hotels"}
]

What should the data structure within the Create JSON module look like to correctly process the input from the Aggregate JSON module?

Create JSON data structure:

Create JSON module configuration:

image

The current setup is producing a plain JSON string and resulting in API errors such as: "JSON parse error: Cannot construct instance of XXXX (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value"

Thanks for your assistance!

 
Posted : 10/04/2025 9:58 am
samliew
(@samliew)
Posts: 293
Reputable Member
 

Instead of a JSON string, I believe you might need an array.

To achieve this, you can attempt to use the JSON "Parse JSON" module to convert your JSON data into an array of accommodations.

For additional details, please refer to in the help center.

Hope this assists you! Feel free to reach out if you have any more questions or encounter further issues.

P.S.: Investing some time in the callin.io Academy can significantly reduce the time and frustration you might experience when using callin.io.

 
Posted : 10/04/2025 11:36 am
Zbulo
(@zbulo)
Posts: 13
Active Member
Topic starter
 

Thanks, this worked!

:slight_smile:

I had to add an Array Aggregator after the Parse JSON to feed it into the Create JSON module.

 
Posted : 10/04/2025 1:19 pm
Share: