EList of strings not being handled properly #100
Unanswered
threadedblue
asked this question in
EMFJson Jackson
Replies: 2 comments
-
All, Solved my own problem. Here's how: Looking through the source code I discovered CollectionDeserializer.
Declare victory!! |
Beta Was this translation helpful? Give feedback.
0 replies
-
The above worked but not really. It work when I had a JSON array of strings but failed with an array populated with any those type. So I am back at square one. I have JSON arrays of string values that I can't get into an EMF EList because they require custom deserialization. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I really like this library. I just need to get around this problem.
Q: Why is my StringDeserializer NOT called on the contents of an array? Is there anyway to get it to do so?
I have a JSON string that contains an array of strings (java.lang.String). The corresponding EMF class has an EList<org.hl7.fhir.String>. Notice we have two different String classes here. The problem seems to be how to convert java.lang.String to org.hl7.fhir.String without a cast?
I implemented a StringDeserializer (way down below) that handles this situation. It works when it it called. i. e. It works on a simple property but it is not called on an array of strings.
When deserializing the JSON below, "city" is handled by the StringDeserializer, but the contents of "line" throws an error:
"Cannot deserialize instance of
com.fasterxml.jackson.databind.JsonNode
out of END_ARRAY token"The JSON in question:
{
"resourceType": "Address",
"city": "GARDNER",
"line": [
"242 GREEN STREET"
]
}
To frame up the problem, how to deserialize "line" : ["abc"]. into EList<org.hl7.fhir.String>?
Adding the deserializer:
module.addDeserializer(org.hl7.fhir.String.class, new StringDeserializer(java.lang.String.class));
The deserializer implementation:
`public class StringDeserializer extends StdDeserializer {
}`
Thanks
Beta Was this translation helpful? Give feedback.
All reactions