...

Package gen

import "github.com/mailru/easyjson/gen"
Overview
Index

Overview ▾

type DefaultFieldNamer

DefaultFieldsNamer implements trivial naming policy equivalent to encoding/json.

type DefaultFieldNamer struct{}

func (DefaultFieldNamer) GetJSONFieldName

func (DefaultFieldNamer) GetJSONFieldName(t reflect.Type, f reflect.StructField) string

type FieldNamer

FieldNamer defines a policy for generating names for struct fields.

type FieldNamer interface {
    GetJSONFieldName(t reflect.Type, f reflect.StructField) string
}

type Generator

Generator generates the requested marshaler/unmarshalers.

type Generator struct {
    // contains filtered or unexported fields
}

func NewGenerator

func NewGenerator(filename string) *Generator

NewGenerator initializes and returns a Generator.

func (*Generator) Add

func (g *Generator) Add(obj interface{})

Add requests to generate marshaler/unmarshalers and encoding/decoding funcs for the type of given object.

func (*Generator) DisallowUnknownFields

func (g *Generator) DisallowUnknownFields()

DisallowUnknownFields instructs not to skip unknown fields in json and return error.

func (*Generator) NoStdMarshalers

func (g *Generator) NoStdMarshalers()

NoStdMarshalers instructs not to generate standard MarshalJSON/UnmarshalJSON methods (only the custom interface).

func (*Generator) OmitEmpty

func (g *Generator) OmitEmpty()

OmitEmpty triggers `json=",omitempty"` behaviour by default.

func (*Generator) Run

func (g *Generator) Run(out io.Writer) error

Run runs the generator and outputs generated code to out.

func (*Generator) SetBuildTags

func (g *Generator) SetBuildTags(tags string)

SetBuildTags sets build tags for the output file.

func (*Generator) SetFieldNamer

func (g *Generator) SetFieldNamer(n FieldNamer)

SetFieldNamer sets field naming strategy.

func (*Generator) SetPkg

func (g *Generator) SetPkg(name, path string)

SetPkg sets the name and path of output package.

func (*Generator) SimpleBytes

func (g *Generator) SimpleBytes()

SimpleBytes triggers generate output bytes as slice byte

func (*Generator) SkipMemberNameUnescaping

func (g *Generator) SkipMemberNameUnescaping()

SkipMemberNameUnescaping instructs to skip member names unescaping to improve performance

func (*Generator) UseLowerCamelCase

func (g *Generator) UseLowerCamelCase()

UseLowerCamelCase sets lowerCamelCase field naming strategy.

func (*Generator) UseSnakeCase

func (g *Generator) UseSnakeCase()

UseSnakeCase sets snake_case field naming strategy.

type LowerCamelCaseFieldNamer

LowerCamelCaseFieldNamer

type LowerCamelCaseFieldNamer struct{}

func (LowerCamelCaseFieldNamer) GetJSONFieldName

func (LowerCamelCaseFieldNamer) GetJSONFieldName(t reflect.Type, f reflect.StructField) string

type SnakeCaseFieldNamer

SnakeCaseFieldNamer implements CamelCase to snake_case conversion for fields names.

type SnakeCaseFieldNamer struct{}

func (SnakeCaseFieldNamer) GetJSONFieldName

func (SnakeCaseFieldNamer) GetJSONFieldName(t reflect.Type, f reflect.StructField) string