SimpleObject JSON Parsing error in werbservices.rest

Reference Application: 2.4:

Question: I am trying to write tests for new allergy api I am adding to webservices.rest. In the tests, I am getting a JSON parsing error because Allergy contains Allergen which contains codedAllergen, a Concept. The parsing (getter conflict) error is the retired field in Concept has two getters isRetired(), and getRetired() I don’t understand because Concept is just a fundamental class so it must be something I am doing wrong. My test extends MainResourceControllerTest

Hello @jdegraft ,

OpenMRS has two getters as you mentioned i.e. isRetired and getRetired, so Jackson can’t automatically convert the data into a JSON object as it gets confused with two getters. You need to convert it into a simpler representation that suits your need like I’m trying to do here while trying to get a base/Raw openmrs object or if there is no preference(for getting JSON) there wont be any exception getting an XML.

@jdegraft, could you please create a pull request so we can see the failing test?

@raff, here is the pull request: https://github.com/openmrs/openmrs-module-webservices.rest/pull/183 thanks

@jdegraft can you say which line of the test in that PR fails, and what the failure is?

@darius, here is the test results:

http://pastebin.com/ahvSGnLn

The errors are mostly in super class tests, though it is also reported for saveAllergy() test I wrote.

I am looking into the DELETE not supported error for delete all allergies a bit more, and this is discussed in this question:

To expound on what @maurya said, the specific problem is that you need to have a Converter or Resource for every non-trivial class that is going to be sent over JSON. Specifically, you need to add a Converter for the Allergen class.