Native Mobile local REST API JSON mapping to data

0
Hi, I am looking to build a Native Mobile app that communicates directly from the client to a REST API, which returns as JSON object. The JSON object is a combination of fields and lists. Example: {     "field1": "val1",     "field2": "val2",     "field3": "val3",     "array1": [{             "array1_field1": "val1a",             "array1_field2": "val2a"         },         {             "array1_field1": "val1b",             "array1_field2": "val2b"         },         {             "array1_field1": "val1c",             "array1_field2": "val2c"         }     ] } Within the infrastructure I need to deploy this, I will not have access to the runtime, and therefore are not able to make the calls and use the JSON mapper via microflows. I have seen the example documented in the link below, but this example only returns a list of objects. https://docs.mendix.com/howto/extensibility/write-javascript-github I need to return / create different objects from the JSON, one for the fields structure, and the others for the lists. I can create a Javascript action and use the FETCH API to retrieve the data, but am having some trouble understanding how I would create different types of Entities to either return from the function, or just create so that they can be retrieved later. The data could be seen as separate entities, but I would also like to link them together with a singleton structure for the fields and it's associated lists, so that when I delete the structure, the lists are cleared too. Could anyone possibly provide any examples of how this would be done using the mx.data framework? Thanks Chris
asked
1 answers
0

The best way to go is to model a domain structure that represents that response. With the API you can then instantiate and link the options. 

You can find API documentation here: https://apidocs.mendix.com/8/client/mx.data.html I do not have an concrete example, but the the API has the description on how to create and link objects.

However, not having access to the Runtime is another concern, this solution does not feel its “the mendix way” as in general  there is always connection to the Runtime and this approach could cause other issues.

answered