json2go

package module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{TypeName: "T"}

Functions

func Generate

func Generate(json string) (string, error)

Generate generates a Go type definition from a JSON string.

func GenerateCode

func GenerateCode(json string) (jen.Code, error)

GenerateCode generates a Go type definition from a JSON string as jen.Code.

func GenerateCodeFromBytes

func GenerateCodeFromBytes(json []byte) (jen.Code, error)

GenerateCodeFromBytes generates a Go type definition from a slice of JSON bytes as jen.Code.

func GenerateFromBytes

func GenerateFromBytes(json []byte) (string, error)

GenerateFromBytes generates a Go type definition from a slice of JSON bytes.

func RenderCode

func RenderCode(code jen.Code) (string, error)

RenderCode renders jen.Code.

Types

type Options

type Options struct {
	TypeName     string
	AllCapsWords []string
}

func (Options) Generate

func (o Options) Generate(json string) (string, error)

Generate generates a Go type definition from a JSON string.

func (Options) GenerateCode

func (o Options) GenerateCode(json string) (jen.Code, error)

GenerateCode generates a Go type definition from a JSON string as jen.Code.

func (Options) GenerateCodeFromBytes

func (o Options) GenerateCodeFromBytes(json []byte) (jen.Code, error)

GenerateCodeFromBytes generates a Go type definition from a slice of JSON bytes as jen.Code.

func (Options) GenerateFromBytes

func (o Options) GenerateFromBytes(json []byte) (string, error)

GenerateFromBytes generates a Go type definition from a slice of JSON bytes.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL