Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Convert ¶
Convert returns a string that converts a JSON string into a Go structure.
return an error if the string is invalid as JSON.
Example ¶
package main import ( "fmt" "github.com/masakurapa/go-json2struct/pkg/j2s" ) func main() { input := `{ "title": "j2s", "snake_case": 99, "CamelCase": true, "kebab-case": null, "map": {"child1": "apple", "child2": 12345}, "slice": ["1", "2", "3", "4", "5"] }` output, err := j2s.Convert(input) if err != nil { fmt.Println(err) return } fmt.Println(output) }
Output: type J2S1 struct { CamelCase bool `json:"CamelCase"` KebabCase interface{} `json:"kebab-case"` Map J2S2 `json:"map"` Slice []string `json:"slice"` SnakeCase int `json:"snake_case"` Title string `json:"title"` } type J2S2 struct { Child1 string `json:"child1"` Child2 int `json:"child2"` }
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.