// unmarshal is equivalent with json.Unmarshal but it converts numbers // to int64 where possible, instead of using always float64. func unmarshal(text []byte, fields *map[string]interface{}) error { dec := json.NewDecoder(bytes.NewReader(text)) dec.UseNumber() err := dec.Decode(fields) if err != nil { return err } jsontransform.TransformNumbers(*fields) return nil }
func DecodeJSON(text []byte, to *interface{}) error { dec := json.NewDecoder(bytes.NewReader(text)) dec.UseNumber() err := dec.Decode(to) if err != nil { return err } switch O := interface{}(*to).(type) { case map[string]interface{}: jsontransform.TransformNumbers(O) } return nil }