Closed threadedblue closed 2 years ago
I'm afraid I can't shed any light on this from the top of my head. Can you please also post the ecore model for which you are running into this issue?
Thanks for your quick response. The ecore is attached. If I can be of help, don't hesitate to task me.
@planger
I apologize. I forgot to include two additional ecore files
namespace.ecore.zip xhtml.ecore.zip
.
@planger
This is quick heads up. We do have two String objects here: java.lang.String and org.hl7.fhir.String. I implemented a string deserializer to sort them out.
In an effort to solve my own problem, I am attempting to implement a custom ContextualDeserializer. I believe the aforementioned tale of two strings (above) is causing the problem. My current StringDeserializer is not being called when deserializing an EList
In the method
public JsonDeserializer<String> createContextual(DeserializationContext ctxt, BeanProperty property)
property is null.
In EObjectFeatureProperty
public void deserializeAndSet(final JsonParser jp, final EObject current, final DeserializationContext ctxt,
final Resource resource)
I find:
final JsonDeserializer<Object> deserializer = ctxt.findContextualValueDeserializer(javaType, null);
Shouldn't the above be called with a non-null BeanProperty?
@planger et. al.
I believe I have found the crux of the problem. My custom string deserializer ( code below ) is not being called when processing the elements of an EList<org.hl7.fhir.String) collection. It is being called at other times. e.g. Address.city, Address.state (JSON below). When the org.hl7.fhir.String is the value of a named type.
In my view EMFJSON-Jackson needs a modification. I am willing to get this done. I am becoming increasingly familiar with the code base. What ever I do, it resides, for the interim, in my own fork.
Q: Would the team like to have this fix?
I am open to any suggestions that my inform my efforts and guide me in implementing something suitable.
Perhaps the best way to put it is: Does the team want EMFJSON-Jackson to support HL7/FHIR or would they prefer the world of health information go its own way with something based on this fine body of good work.
The aforementioned JSON:
{
"city": "Albuquerque",
"state": "NM",
"line": [
"123 Applewood ln"
],
"resourceType": "Address",
"id": "e44f438a-601b-30fb-85eb-bfaf8ddcb5ad"
}
The aforementioned StringDeserializer:
public class StringDeserializer extends JsonDeserializer<org.hl7.fhir.String> implements ContextualDeserializer {
private JavaType valueType;
@Override
public StringDeserializer createContextual(DeserializationContext ctxt, BeanProperty property) {
JavaType type = ctxt.getContextualType() != null
? ctxt.getContextualType()
: property.getMember().getType();
return new StringDeserializer();
}
@Override
public org.hl7.fhir.String deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
org.hl7.fhir.String s = FhirFactory.eINSTANCE.createString();
s.setValue(p.getValueAsString());
return s;
}
}
My fix is working for now. Closing this issue.
I believe we have. a bug in EMFJSON-Jackson. Things work when processing the same JSON using Jackson and congruous non-EMF POJOs.
I can explain the situation further but I am afraid of overloading the explanation and clouding the issue. I am hoping to spark some interaction with someone who is knowledgeable. The resolution of this issue is important to me and I am willing put in some effort.
The error message:
Cannot deserialize value of type
com.fasterxml.jackson.databind.JsonNode
from Array value (tokenJsonToken.END_ARRAY
) at [Source: UNKNOWN; line: -1, column: -1The JSON:
btw: I do find this comment in the Jackson code base to be puzzling and it appears to be relevant to the issue.
The code from Jackson JsonNodeDeserializer: