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.
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