本文整理汇总了Golang中kego/io/system.String.Unpack方法的典型用法代码示例。如果您正苦于以下问题:Golang String.Unpack方法的具体用法?Golang String.Unpack怎么用?Golang String.Unpack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kego/io/system.String
的用法示例。
在下文中一共展示了String.Unpack方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Unpack
func (v *Page) Unpack(ctx context.Context, in system.Packed, iface bool) error {
if in == nil || in.Type() == system.J_NULL {
return nil
}
if v.Object == nil {
v.Object = new(system.Object)
}
if err := v.Object.Unpack(ctx, in, false); err != nil {
return err
}
if err := v.Object.InitializeType("kego.io/demo/demo2", "page"); err != nil {
return err
}
if field, ok := in.Map()["hero"]; ok && field.Type() != system.J_NULL {
ob0 := new(images.Photo)
if err := ob0.Unpack(ctx, field, false); err != nil {
return err
}
v.Hero = ob0
}
if field, ok := in.Map()["title"]; ok && field.Type() != system.J_NULL {
ob0 := new(system.String)
if err := ob0.Unpack(ctx, field, false); err != nil {
return err
}
v.Title = ob0
}
return nil
}
示例2: Unpack
func (v *F) Unpack(ctx context.Context, in system.Packed, iface bool) error {
if in == nil || in.Type() == system.J_NULL {
return nil
}
if v.Object == nil {
v.Object = new(system.Object)
}
if err := v.Object.Unpack(ctx, in, false); err != nil {
return err
}
if err := v.Object.InitializeType("kego.io/process/validate/tests", "f"); err != nil {
return err
}
if field, ok := in.Map()["a"]; ok && field.Type() != system.J_NULL {
ob0 := new(A)
if err := ob0.Unpack(ctx, field, false); err != nil {
return err
}
v.A = ob0
}
if field, ok := in.Map()["b"]; ok && field.Type() != system.J_NULL {
if field.Type() != system.J_ARRAY {
return fmt.Errorf("Unsupported json type %s found while unpacking into an array.", field.Type())
}
ob0 := []*A{}
for i0 := range field.Array() {
ob1 := new(A)
if err := ob1.Unpack(ctx, field.Array()[i0], false); err != nil {
return err
}
ob0 = append(ob0, ob1)
}
v.B = ob0
}
if field, ok := in.Map()["c"]; ok && field.Type() != system.J_NULL {
if field.Type() != system.J_MAP {
return fmt.Errorf("Unsupported json type %s found while unpacking into a map.", field.Type())
}
ob0 := map[string]*A{}
for k0 := range field.Map() {
ob1 := new(A)
if err := ob1.Unpack(ctx, field.Map()[k0], false); err != nil {
return err
}
ob0[k0] = ob1
}
v.C = ob0
}
if field, ok := in.Map()["d"]; ok && field.Type() != system.J_NULL {
ob0 := new(system.String)
if err := ob0.Unpack(ctx, field, false); err != nil {
return err
}
v.D = ob0
}
return nil
}
示例3: Unpack
func (v *Photo) Unpack(ctx context.Context, in system.Packed, iface bool) error {
if in == nil || in.Type() == system.J_NULL {
return nil
}
if v.Object == nil {
v.Object = new(system.Object)
}
if err := v.Object.Unpack(ctx, in, false); err != nil {
return err
}
if err := v.Object.InitializeType("kego.io/demo/demo3/images", "photo"); err != nil {
return err
}
if field, ok := in.Map()["url"]; ok && field.Type() != system.J_NULL {
ob0 := new(system.String)
if err := ob0.Unpack(ctx, field, false); err != nil {
return err
}
v.Url = ob0
}
return nil
}
示例4: Unpack
func (v *Photo) Unpack(ctx context.Context, in system.Packed, iface bool) error {
if in == nil || in.Type() == system.J_NULL {
return nil
}
if v.Object == nil {
v.Object = new(system.Object)
}
if err := v.Object.Unpack(ctx, in, false); err != nil {
return err
}
if err := v.Object.InitializeType("kego.io/demo/common/images", "photo"); err != nil {
return err
}
if field, ok := in.Map()["path"]; ok && field.Type() != system.J_NULL {
ob0 := new(system.String)
if err := ob0.Unpack(ctx, field, false); err != nil {
return err
}
v.Path = ob0
}
if field, ok := in.Map()["protocol"]; ok && field.Type() != system.J_NULL {
ob0 := new(system.String)
if err := ob0.Unpack(ctx, field, false); err != nil {
return err
}
v.Protocol = ob0
} else {
ob0 := new(system.String)
if err := ob0.Unpack(ctx, system.Pack("http"), false); err != nil {
return err
}
v.Protocol = ob0
}
if field, ok := in.Map()["server"]; ok && field.Type() != system.J_NULL {
ob0 := new(system.String)
if err := ob0.Unpack(ctx, field, false); err != nil {
return err
}
v.Server = ob0
}
if field, ok := in.Map()["size"]; ok && field.Type() != system.J_NULL {
ob0 := new(units.Rectangle)
if err := ob0.Unpack(ctx, field, false); err != nil {
return err
}
v.Size = ob0
}
return nil
}
示例5: Unpack
func (v *Simple) Unpack(ctx context.Context, in system.Packed, iface bool) error {
if in == nil || in.Type() == system.J_NULL {
return nil
}
if v.Object == nil {
v.Object = new(system.Object)
}
if err := v.Object.Unpack(ctx, in, false); err != nil {
return err
}
if err := v.Object.InitializeType("kego.io/demo/demo5/translation", "simple"); err != nil {
return err
}
if field, ok := in.Map()["text"]; ok && field.Type() != system.J_NULL {
ob0 := new(system.String)
if err := ob0.Unpack(ctx, field, false); err != nil {
return err
}
v.Text = ob0
}
return nil
}