DecodeFieldsJSON decodes an item's fields blob with every number kept as the literal it was written as (a json.Number), for code that decodes a blob in order to WRITE it back (BUG-3202). A plain json.Unmarshal into map[string]any turns each number into a float64, so the re-encode rounds an integer
(raw []byte)
| 30 | // A literal `null` decodes to a nil map with no error, as it does through |
| 31 | // Unmarshal; callers keep their existing handling of that case. |
| 32 | func DecodeFieldsJSON(raw []byte) (map[string]any, error) { |
| 33 | var m map[string]any |
| 34 | if err := DecodeJSONKeepingNumbers(raw, &m); err != nil { |
| 35 | return nil, err |
| 36 | } |
| 37 | return m, nil |
| 38 | } |
| 39 | |
| 40 | // DecodeJSONKeepingNumbers is DecodeFieldsJSON for any target: v must be a |
| 41 | // pointer, as for json.Unmarshal. The range check covers numbers held in |