Providing an additional static method 'setupDefaultMapper' with a parameter of type com.fasterxml.jackson.core.JsonFactory would allow to put e.g. a YamlFactory as constructor parameter for the ObjectMapper instance.
So there would be the possibilty to extend EMFJson to serialize/deserialize YAML without further changes.
We already tested it for serializing YAML which worked.
public static ObjectMapper setupDefaultMapper() {
return setupDefaultMapper(null);
}
public static ObjectMapper setupDefaultMapper(JsonFactory factory) {
final ObjectMapper mapper = factory == null ? new ObjectMapper() : new ObjectMapper(factory);
// same as emf
final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH);
dateFormat.setTimeZone(TimeZone.getDefault());
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
mapper.setDateFormat(dateFormat);
mapper.setTimeZone(TimeZone.getDefault());
mapper.registerModule(new EMFModule());
return mapper;
}
You can that say:
ObjectMapper mapper = EMFModule.setupDefaultMapper(new YamlFactory());
Providing an additional static method 'setupDefaultMapper' with a parameter of type com.fasterxml.jackson.core.JsonFactory would allow to put e.g. a YamlFactory as constructor parameter for the ObjectMapper instance.
So there would be the possibilty to extend EMFJson to serialize/deserialize YAML without further changes.
We already tested it for serializing YAML which worked.
You can that say:
ObjectMapper mapper = EMFModule.setupDefaultMapper(new YamlFactory());
https://github.com/FasterXML/jackson-dataformats-text/tree/master/yaml