Rest Module using dynamic key name

1
Hi I am currently using the rest module to integrate with the rest services provided by docker. I have the majority of my desired functionality working, however there is one piece that I am struggling to create/map. Some of the Json that is provided to the services is dynamic. By this I mean the key is unknown/dynamic, so is not a fixed key. This means I would like to map it to an object that just contains key and field. For example: "Volumes":{ "/tmp": {} }, Or "Volumes":{"/var/log":"true"} The "/tmp" part could be anything, which means it I can't map it into Mendix, or send a post message with the same structure. I have seen that there is a primitive types object in the rest module. Would I be able to use this? Or does it only allow single values like: ["simon","david"] If the module has this functionality already then let me know, otherwise I will look into extending the functionality. Regards Simon
asked
1 answers
0

suppose the value of "/tmp" is stored in the association "mymodule.dynamicrelation", introduce an string type attribute named "dynamicrelation_jsonkey", and give it just before serialization the value "/tmp" (or whathever you need).

That should do the trick, "_jsonkey" attributes are used to serialize strangely named attributes, and take precedence over the attribute name itself.

See: https://github.com/mendix/restservices#serializing-complex-attribute-names

answered