本文整理匯總了Golang中github.com/antonholmquist/jason.Object.Object方法的典型用法代碼示例。如果您正苦於以下問題:Golang Object.Object方法的具體用法?Golang Object.Object怎麽用?Golang Object.Object使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/antonholmquist/jason.Object
的用法示例。
在下文中一共展示了Object.Object方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: parseCondition
func parseCondition(v *jason.Object) (c *Condition, err error) {
conds, err := v.Object()
if conds == nil {
fmt.Println("get conds failed")
return nil, err
}
c = &Condition{}
for ck, cv := range conds.Map() {
ea := &[]Expression{}
eo, err := cv.Object()
if err != nil {
// cv is value
e := &Expression{}
e.op = "$eq"
switch cv.Interface().(type) {
case []interface{}:
e.value, _ = cv.Array()
case bool:
e.value, _ = cv.Boolean()
case string:
e.value, _ = cv.String()
case json.Number:
e.value, _ = cv.Number()
default:
continue
/*
e.value = cv.Interface()
fmt.Println(cv, " unsupported type ",
reflect.ValueOf(cv.Interface()).Type())
*/
}
*ea = append(*ea, *e)
} else {
// cv is a object
i := 0
for ek, ev := range eo.Map() {
e := &Expression{}
e.op = ek
switch ev.Interface().(type) {
case []interface{}:
e.value, _ = ev.Array()
case bool:
e.value, _ = ev.Boolean()
case string:
e.value, _ = ev.String()
case json.Number:
e.value, _ = ev.Number()
default:
continue
/*
e.value = ev.Interface()
fmt.Println(ev, " unsupported type ",
reflect.ValueOf(ev.Interface()).Type())
*/
}
*ea = append(*ea, *e)
i += 1
}
}
(*c)[ck] = ea
}
return c, nil
}