cadence-java-client icon indicating copy to clipboard operation
cadence-java-client copied to clipboard

Suggestion replacing Gson with Jackson in default DataConverter implementation

Open mr2chethan opened this issue 8 months ago • 0 comments

Currently gson is being used in JsonDataConverter https://github.com/cadence-workflow/cadence-java-client/blob/master/src/main/java/com/uber/cadence/converter/JsonDataConverter.java . Gson has many limitations like:

  1. Handling LocalDate, LocalDateTime, etc Java 8 date/time types ex.
LocalDate date = LocalDate.now();
Gson gson = new Gson();
String json = gson.toJson(date);  // Outputs: "\"2025-04-14\""
LocalDate parsed = gson.fromJson(json, LocalDate.class);  // Exception: can't deserialize
  1. Handling polymorphism ex.
Animal dog = new Dog();
Gson gson = new Gson();
String json = gson.toJson(dog);  // Loses type info
Animal animal = gson.fromJson(json, Animal.class);  // Deserializes to Animal only, no Dog
  1. Performance

Jackson is faster for both serialization & deserialization esp for larger and nested payloads.

I would like to propose replacing Gson with Jackson as the default implementation or providing a first-party JacksonDataConverter alongside the existing Gson one, with an easy way for developers to plug it in.

Happy to contribute a PR if this sounds acceptable.

mr2chethan avatar Apr 15 '25 01:04 mr2chethan