Json deserialize

When using this post to deserialize a json response, I run into a problem. I understand that the name of an association is important when deserializing and that the name of an association in a mendix module must me unique. The json response contains a member("errors":["Waarde mag niet leeg zijn"]) that occurs in several other members. I have converted the (a part of) Json to XML to make it more readable: <address> <errors> <element>Waarde mag niet leeg zijn</element> </errors> </address> <birthdate> <errors> <element>Waarde mag niet leeg zijn</element> </errors> </birthdate> In the domain model, errors will be the name of the association to link address with element. I can use errors only once as name of the association. So, how can I associate birthdate to element? Only having address (entity) - errors (association) - element (entity) does not work anyway. After deserializing, the element entity is empty. The other part of the json response (which I haven't put in this post) is deserialized correctly. Update 1: The problem is that the error part in Json contains a string, where Mendix expects an arrays of objects. Here is the Json part: "address":{"errors":["Waarde mag niet leeg zijn"],"valid":false,"value":null},"birthdate":{"errors":["Waarde mag niet leeg zijn"],"valid":false,"value":null} Update 2: Problem solved using: entity _error (generalize from restservice.primitive) entity errorhelper (association * > * with _error called errors) entity address (generalize from errorhelper) entity birthdate (generalize from errorhelper
1 answers

According to the provided json you have shown, i think the following structure would suffice:

create 4 non-persistable entities

  • request
  • address (attributes: valid of type boolean, value of type string)
  • _errors (1 attribute of type string called element)
  • _element (generalization of primitive in REST module)

create associations:

  • request * > 1 address (name association: _request_address)
  • request * > 1 birthdate (name association:_request_birthdate)
  • address * > 1 _errors (name association: _address_errors)
  • _errors * > * _element (name association: errors)

The rest microflow called should loop through the Requests and this would automatically map the associations, the deserialization java action should not be needed. It then can be mapped to your database.