Ejemplo n.º 1
0
func main() {
	var jsonStream string = `
	{"Name": "Ming", "Age": 32, "Address": "Taipei, Taiwan"}
`
	output, _ := jsonToGo.Gen(jsonStream, "taipeiCity")
	fmt.Println(output)
}
Ejemplo n.º 2
0
func ExampleGen() {
	var jsonStream string = `
{"message": "Hello World", "size": 32, "number": 1.234}
`
	output, _ := jsonToGo.Gen(jsonStream, "test")
	fmt.Println(output)
	//Output:
	////go:generate ginger $GOFILE
	//package main
	//
	////@ginger
	//type Test struct {
	//	Ginger_Created int32 `json:"ginger_created"`
	//	Ginger_Id int32 `json:"ginger_id" gorm:"primary_key"`
	//
	//	Message string `json:"message"`
	//	Size float64 `json:"size"`
	//	Number float64 `json:"number"`
	//}
}
Ejemplo n.º 3
0
func genJsonToGo(obj Onion) {
	output, _ := jsonToGo.Gen(obj.JsonSchema, obj.TypeName)
	writeFile("./workspace/"+obj.DomainName+"."+obj.TypeName+"/onion", "onion.go", output)
}