Skip to content

Cannot configure default GsonSupport #386

@romanmusii

Description

@romanmusii

The default JsonSupport comes with GsonSupport class with predefined configuration:

  private static class GsonCompressedHolder {

    private static final Gson INSTANCE = new GsonBuilder()
        .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
        .registerTypeAdapter(OFFSET_DATE_TIME_TYPE, new OffsetDateTimeSerdes())
        .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
        .create();
  }

  private static class GsonHolder {

    private static final Gson INSTANCE = new GsonBuilder()
        .setPrettyPrinting()
        .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
        .registerTypeAdapter(OFFSET_DATE_TIME_TYPE, new OffsetDateTimeSerdes())
        .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
        .create();
  }

It's pretty common case that we need to specify another parameters for Gson INSTANCE - for example, field naming policy. The decision for now is to define our own JsonSupport implementation and specify Gson as we need it. But it seems to me that it can be more easy to support this feature in nakadi-java: provide your own Gson object or parameters to create Gson objectn during creation of NakadiClient.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions