You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 26, 2021. It is now read-only.
I have a valid json that I created with this library. I then try to deserialize it back into this EMap.
Expected: The values in the map entries would be EList instances.
Actual: ClassCast exceptions.
The org.emfjson.jackson.databind.deser.EMapDeserializer sees a token that is not START_OBJECT (but rather START_ARRAY) and performs a readValue with Object.class. Jackson does its lookups and concludes a com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer should be used, and this creates an ArrayList at line 840.
The org.eclipse.emf.ecore.util.EcoreEMap runs a setValue on line 270 with the ArrayList value, and this triggers a ClassCastException because this list should have been an EList.
Perhaps do a check for START_ARRAY in EMapDeserializer#57 and treat this differently?
Register EList as a deserialization class for json array
Check in EMapDeserializer if the value is ArrayList and convert it to EList. I think this is a bad solution; more of a band-aid fix for this particular case
Thanks!
The text was updated successfully, but these errors were encountered:
krissrex
changed the title
EMapDeserialiser creates ArrayList instead of EList when map value is a list
EMapDeserializer creates ArrayList instead of EList when map value is a list
Feb 24, 2021
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Description: I am trying to deserialize an
EMap
withBasicEMap.Entry<String,EList<String>>
as its contents.Example of this structure:
It uses this construct from Ecore:
I have a valid json that I created with this library. I then try to deserialize it back into this
EMap
.Expected: The values in the map entries would be
EList
instances.Actual: ClassCast exceptions.
The
org.emfjson.jackson.databind.deser.EMapDeserializer
sees a token that is notSTART_OBJECT
(but ratherSTART_ARRAY
) and performs areadValue
withObject.class
. Jackson does its lookups and concludes acom.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer
should be used, and this creates anArrayList
at line840
.The
org.eclipse.emf.ecore.util.EcoreEMap
runs asetValue
on line 270 with theArrayList
value, and this triggers aClassCastException
because this list should have been anEList
.Stacktrace:
Assumed fixes:
START_ARRAY
inEMapDeserializer#57
and treat this differently?EList
as a deserialization class for json arrayEMapDeserializer
if the value isArrayList
and convert it toEList
. I think this is a bad solution; more of a band-aid fix for this particular caseThanks!
The text was updated successfully, but these errors were encountered: