Skip to content

VaLeraGav/jsonstruct

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

jsonstruct

Library convert json to struct.

func main() {
	jsonStr := `{
	"query": "Виктор Иван",
	"count": 7,
	"parts": [{"sdfsdf" : 12}]
	}`

	acc, err := jsonstruct.Convert(jsonStr, "Name")
	if err != nil {
		return "", fmt.Errorf("Convert: %w", err)
	}

	err = jsonstruct.WriteFile("./name.go", acc)
	if err != nil {
		return "", fmt.Errorf("WriteFile: %w", err)
	}
}

./name file will be created.go to the root

type Parts struct {
        Count int `json:"count"`
}
type Name struct {
        Count   int     `json:"count"`
        Parts   []Parts `json:"parts"`
        Query   string  `json:"query"`
}

About

convert json to struct

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages