README ¶ jsonutil golang json utils for common use Basic Usage Installation To get the package, execute: go get github.com/gofika/jsonutil Example package main import ( "fmt" "github.com/gofika/jsonutil" ) type Foo struct { Name string `json:"name"` Value int `json:"value"` } func main() { foo := &Foo{ Name: "Jason", Value: 100, } name := "foo.json" // write struct to file err := jsonutil.WriteFile(name, foo) if err != nil { fmt.Printf("WriteFile failed. err: %s\n", err.Error()) return } // read struct from file bar, err = jsonutil.ReadFile[Foo](name) if err != nil { fmt.Printf("ReadFile failed. err: %s\n", err.Error()) return } fmt.Printf("bar.Name: %s\n", bar.Name) fmt.Printf("bar.Value: %d\n", bar.Value) } Expand ▾ Collapse ▴ Documentation ¶ Index ¶ func ReadFile[T any](filename string) (T, error) func ReadFileAny(filename string, v any) error func WriteFile(filename string, v any) error func WriteFileIndent(filename string, v any, indent string) error Constants ¶ This section is empty. Variables ¶ This section is empty. Functions ¶ func ReadFile ¶ func ReadFile[T any](filename string) (T, error) ReadFile read struct from json file func ReadFileAny ¶ func ReadFileAny(filename string, v any) error ReadFileAny read struct from json file func WriteFile ¶ func WriteFile(filename string, v any) error WriteFile write struct to json file func WriteFileIndent ¶ func WriteFileIndent(filename string, v any, indent string) error WriteFileIndent write struct to json file with indent Types ¶ This section is empty. Source Files ¶ View all Source files file.go Click to show internal directories. Click to hide internal directories.