bitly / go-simplejson

a Go package to interact with arbitrary JSON
MIT License
3.76k stars 498 forks source link

get json object error #62

Open boneLau opened 7 years ago

boneLau commented 7 years ago

first "Set" a json object into a new json object, and then the new json object "Get" the json out is error.because is the json address.

func (j *Json) Get(key string) *Json {
    m, err := j.Map()
    if err == nil {
        if val, ok := m[key]; ok {
            /////this may be used
            if reflect.TypeOf(val).Kind() == reflect.Ptr {
                if reflect.TypeOf(val).Elem().String() == "simplejson.Json"{
                    return val.(*Json)
                }else{
                    return &Json{nil}
                }
            }
            return &Json{val}
        }
    }
    return &Json{nil}
}