Skip to content

Marshal with case preference #271

@jhwz

Description

@jhwz

Would it be possible to create an option for the encoder to be able to specify the case style the struct fields are marshalled with?

For example, if we have

type mystruct struct {
   FieldOne string
   FieldTwo string
} 

the output will be

{
  "FieldOne" : "",
  "FieldTwo" : ""
}

but if we could specify an option to convert to say camelcase (even something as simple as lowercase the first letter) to get

{
  "fieldOne" : "",
  "fieldTwo" : ""
}

it would be much nicer than manually specifying json tags! Not sure how it would look in terms of performance. Obviously a general solution is a callback/transformation function of some kind, or could just support camelCase as that would be fast.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions