REST endpoint sends variable objects instead of array

Hi,   Does someone know of a way to work with an REST endpoint that sends back variable objects instead of an array?   We are currently building an REST API connection where we have run into a difficulty. We are calling an endpoint which returns different objects depending on the used parameter. The returned objects are fields which we have to use to assemble another JSON. In the fields object we are mainly concerned with the key attribute, seeing as we have to use those as attributes in the new JSON. The different field objects have a similar structure:   "<field key, object name>": {                  "key": <string, field key>,                  "name": <string>,                  "description": <string>,                  "required": <boolean, [true|false]>,                  "type": <string, [TEXT|INTEGER|DATE]>,                  "refData": <string, optional, [TRUE|ONLY]>,                  "parentKey": <string, optional, key of a parent field>,                  "values": <page, full list of valid values from reference data> }   This results in a JSON, that looks something like this:   {   "id": "string",   "name": "string",   "fields": {     "surname": {       "key": "surname",       "name": "Last Name",       "description": null,       "required": true,       "type": "TEXT",       "refData": null,       "parentKey": null,       "values": null                               },     "gender": {       "key": "gender",       "name": "Gender",       "description": null,       "required": true,       "type": "TEXT",       "refData": "ONLY",       "parentKey": null,       "values": null                               }                } }   Because the objects are not part of an array, but are send as different unique objects it is hard to apply an import mapping.   For now the best solution we see is to make non-persistable objects of all the known objects that could be send, like surname and gender. Aside from a messy domain-model there is a more important issue with this solution, which is that it could change at any given time. Certain field objects might be added or get a change in name. We would therefore prefer a more variable solution if possible.   Kind regards,   Davy
1 answers

Hi Davy,

Have a look at the JSON Structure module. There's also a blog describing a similar problem here.


Good luck!