JSON rest response: Array contains multiple JSON object definitions. Only first will be used. How to fix this?

1
See my JSON response below:  The Answer items have a different 'answer type in this example ' : 'text' ''email' or 'boolean'. Mendix gives a warning 'array contains multiple JSON object definitions. Only the first answer type will be used' when I try to create the import mapping for this json response. The consequence is that my Answer data in my Mendix domain only can store the 'email'  value at the moment. I don't get the text and boolean values :-( How can I solve this? I want to store al the answer types of my response... Thanks!! { "total_items": 3, "page_count": 1, "items": [ { "landing_id": "e2e53820aa8752a5f452e574aca8330c", "token": "e2e53820aahjhjhh52e574aca8330c", "landed_at": "2018-04-06T14:12:23Z", "submitted_at": "2018-04-06T14:12:59Z", "metadata": { "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0.3 Safari/604.5.6", "platform": "other", "referer": "https://blabla.typeform.com/to/xtFNKB", "network_id": "71fd213e1b", "browser": "default" }, "answers": [ { "field": { "id": "R8pzY31ImdwV", "type": "email", "ref": "08f23377-600d-4eb2-959e-74f17bbe6646" }, "type": "email", "email": "cillus@fcillus.com" }, { "field": { "id": "i82bihFFjHK5", "type": "short_text", "ref": "751fb3be-b6f1-4e55-8050-94973533ac7b" }, "type": "text", "text": "How do I get a nice job" }, { "field": { "id": "KuNzOEbVzj1O", "type": "short_text", "ref": "44514361-e85f-42e7-ae04-bf447b739e14" }, "type": "text", "text": "Cillus" }, { "field": { "id": "XQnOHsEHhJrD", "type": "yes_no", "ref": "347b904d-87c5-47ab-bd09-a64dd1534aac" }, "type": "boolean", "boolean": true } ], "hidden": {}, "calculated": { "score": 0 }    
asked
2 answers
3

Try using this as your JSON template: here we're essentially adding all permutations of attributes of an Answer in the first one in the list. This will tell the modeler to consider all of those as possible attributes of the Answer.

 

{
    "total_items": 3,
    "page_count": 1,
    "items": [
        {
            "landing_id": "e2e53820aa8752a5f452e574aca8330c",
            "token": "e2e53820aahjhjhh52e574aca8330c",
            "landed_at": "2018-04-06T14:12:23Z",
            "submitted_at": "2018-04-06T14:12:59Z",
            "metadata": {
                "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0.3 Safari/604.5.6",
                "platform": "other",
                "referer": "https://blabla.typeform.com/to/xtFNKB",
                "network_id": "71fd213e1b",
                "browser": "default"
            },
            "answers": [
                {
                    "field": {
                        "id": "R8pzY31ImdwV",
                        "type": "email",
                        "ref": "08f23377-600d-4eb2-959e-74f17bbe6646"
                    },
                    "type": "email",
                    "email": "cillus@fcillus.com",
                    "text": "How do I get a nice job",
                    "boolean": true,

                }
            ],
            "hidden": {},
            "calculated": {
                "score": 0
            }

 

answered
0

Hi Cillus,

I was able to recreate your issue in a test project. I'm not too sure how to get the import mapping to work with that structure, but you could try using the json transform module in the app store to create a new structure that would import correctly.

https://appstore.home.mendix.com/link/app/106051/

answered