eclipse-emfcloud / emfjson-jackson

emfjson-jackson
Other
17 stars 15 forks source link

An EMap Entry with a null key raises an NPE #32

Closed vhemery closed 2 years ago

vhemery commented 2 years ago

See https://github.com/eclipse-emfcloud/emfcloud/discussions/155 for broader context

Use a metamodel with an EMap reference (a multivalued reference with type pointing to an EStringToStringMapEntry Eclass, with java.util.Map$Entry instance type name). When you instantiate a map entry with the null key, it makes org.eclipse.emfcloud.jackson.databind.ser.EMapStringSerializer.serialize(EList<Entry<String, ?>>, JsonGenerator, SerializerProvider) crash with NPE.

Since Map keys in json are only strings, null can not be used. It would be acceptable to have a default key configured instead of null (probably empty string). Ideally we could configure this default key value with jackson. (see https://www.baeldung.com/jackson-map-null-values-or-null-key )

Note I am willing to contribute on this.