jsongen

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 11 Imported by: 0

README

jsongen

convert json to go source code

refer to json2struct_test.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Json2Struct

func Json2Struct(jsontext []byte, writer io.Writer, options *Options) error

convert json to struct and write to writer

func Json2StructDir

func Json2StructDir(jsondir string, dir string, options *Options) error

convert jsonfiles in jsondir to go structs and put the in dir if options have no value, Package and Type will be guessed from folder and file name

func Json2StructFile

func Json2StructFile(jsonfile string, gofile string, options *Options) error

convert jsonfile to gofile if options doesn't have value, Package and Type will be guessed as per folder and file name

func Title

func Title(name string) string

Types

type Options

type Options struct {
	Package   string
	Type      string
	Unmarshal func(data []byte, v any) error
}

type StructGen

type StructGen struct {
	Name     string
	Data     map[string]any
	Meta     map[string]string
	Children []*StructGen
}

func (*StructGen) Json2Struct

func (s *StructGen) Json2Struct(jsondata []byte, writer io.Writer, options *Options) error

Jump to

Keyboard shortcuts

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