iancoleman / orderedmap

orderedmap is a golang map where the keys keep the order that they're added. It can be de/serialized from/to JSON. It's based closely on the python collections.OrderedDict.
MIT License
360 stars 55 forks source link

JSON decoder.UseNumber not working #12

Closed defool closed 4 years ago

defool commented 5 years ago
func TestOrderedMap_UseNumber(t *testing.T) {
    srcStr := `{"x":1}`
    om := New()
    d := json.NewDecoder(strings.NewReader(srcStr))
    d.UseNumber()
    d.Decode(om)
    if v, ok := om.Get("x"); ok {
        if _, ok := v.(json.Number); !ok {
            t.Errorf("Expect type is json.Number, got %v", reflect.TypeOf(v))
        }
    }
}

Shows: Expect type is json.Number, got float64