wso2 / msf4j

WSO2 Microservices Framework for Java (MSF4J)
http://wso2.com/products/microservices-framework-for-java/
Apache License 2.0
401 stars 349 forks source link

Register custom Gson Type adapter #542

Open mynecker opened 6 years ago

mynecker commented 6 years ago

It would be helpful to be able to register custom Gson-Type adapters [1] for serialization and deserialization of Json payloads.

Gson gson = new GsonBuilder().registerTypeAdapter(MyClass.class, new MyAdapter()).create();

[1] https://google.github.io/gson/apidocs/com/google/gson/TypeAdapter.html

this commented 5 years ago

@mynecker Currently we don't have any plans on implementing this. As a workaround, you can call Gson by yourself and then set the output JSON string to the response.

inem88 commented 5 years ago

I found solution for custom format fields, for example OffsetDateTime. See https://github.com/wso2/msf4j/issues/415#issuecomment-428944040