Skip to content

Add option to use snake_case names by for serialization by default #198

Closed
@jakemac53

Description

@jakemac53

I think this should live on the JsonSerializable annotation, and would apply to all fields under the annotated object.

Example usage:

@JsonSerializable(snakeCaseFields: true)
class Thing {
  final Thing nestedThing;
}

Would be equivalent to the following:

@JsonSerializable()
class Thing {
  @JsonKey(name: 'nested_thing')
  final Thing nestedThing;
}

Enums are a bit of an edge case, its not clear if it should apply automatically to enum values or not. One specific edge case here is if an enum value has its own explicit JsonKey annotation, once that is supported. Would that always override this setting?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions