Exporting Mendix Object into Json with a list of integers

0
I want to export to JSON into a structure like this: {     "fileName": "776.pdf",     "brokerID": "426",     "description": "System Tag",     "released": true,     "serviceClientID": "921",     "tags": [         1,         3     ] } It seems mendix can only list objects and not other data types. How would I go about getting this as my resulting JSON structure.
asked
4 answers
3

Let Mendix Studio Pro help you out: 

  • Make a ‘JSON structure’ using this string:
{
    "fileName": "776.pdf",
    "brokerID": "426",
    "description": "System Tag",
    "released": true,
    "serviceClientID": "921",
    "tags": [
        1,
        3
    ]
}
  • Create an import mapping using this JSON and click ‘Map automatically’
  • Create a Message definition and add the newly created entity
  • Create an export mapping using button ‘Generate mapping(s)’

Hm, seems you are right. Only a list of objects and not your prefered list of integers, which is also correct JSON. Either:

- untick 'tag' in the export mapping and manually postprocessing the JSONstring to add a string containing the list of tags in your required format

- or do a replace of “tags”:[‘*’] by  a string containing the list of tags in your required format

 

answered
0

Just define a JSON Structure and use that in an export mapping.
Mendix indeed does only support entities in the datamodel, but will automatically convert a JSON array into an entitity structure.
See https://docs.mendix.com/refguide/json-structures/#22-json-arrays

answered
0

Hi Nicholas,
You can create a message definition for your entity by ticking all necessary attributes and associations, and then create an export mapping for you message definition and call it in a microflow or just drag and drop export mapping into your microflow.
 

answered
0

You can not create a JSON array of strings or integers while using an export mapping. You need to create this array yourself using a variable and replace the object array. 

answered