github.com/goplus/llgo@v0.8.3/c/cjson/_demo/mkjson/mkjson.go (about) 1 package main 2 3 import ( 4 "github.com/goplus/llgo/c" 5 "github.com/goplus/llgo/c/cjson" 6 ) 7 8 func main() { 9 mod := cjson.Object() 10 mod.SetItem(c.Str("name"), cjson.String(c.Str("math"))) 11 12 syms := cjson.Array() 13 14 fn := cjson.Object() 15 fn.SetItem(c.Str("name"), cjson.String(c.Str("sqrt"))) 16 fn.SetItem(c.Str("sig"), cjson.String(c.Str("(x, /)"))) 17 syms.AddItem(fn) 18 19 v := cjson.Object() 20 v.SetItem(c.Str("name"), cjson.String(c.Str("pi"))) 21 syms.AddItem(v) 22 23 mod.SetItem(c.Str("items"), syms) 24 25 c.Printf(c.Str("%s\n"), mod.CStr()) 26 mod.Delete() 27 }