|
Re: Deserializing JSON to EMF [message #1745956 is a reply to message #1745954] |
Wed, 19 October 2016 19:33 |
Erdal Karaca Messages: 854 Registered: July 2009 |
Senior Member |
|
|
I have no experience with Jackson... Maybe it searches not for the interface to deserialize but the impl class, i.e. ForecastPatientImpl which your method does not have as return type?
BTW, Eclipse Texo has built-in support for serializing/deserializing EMF models for use in web services. It uses the org.json library, though.
Geoffry Roberts wrote on Wed, 19 October 2016 20:42I am posting here out of desperation in hope that someone in the EMF community has solved this problem. The issue is not directly related to EMF but rather with the utility FasterXMLJackson.
When I serialize anything EMF using Jackson, it works and life is good. But not so the return trip. This is because for deserialization, Jackson wants a no-arg constructor by default and EMF ain't got one. To solve this, one can use one of Jackson's annotations @JsonCreator and create a "mixin". I did this but still no go. Here's what I have to date:
My mixin, which by all accounts seems correct.
public class PatientMixin {
@JsonCreator
public static ForecastPatient createForecastForecastPatient() {
return ForecastFactory.eINSTANCE.createForecastPatient();
}
}
Then we have to tell Jackson how to use it.
ObjectMapper mapper = new ObjectMapper();
mapper.addMixIn(ForecastPatient.class, PatientMixin.class);
It doesn't work. I get the same error I would get if I did none of this.
Surely someone has made EMF work with Jackson.
Thanks for your patience.
|
|
|
|
Powered by
FUDForum. Page generated in 0.02514 seconds