MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / DecodeFieldsJSON

Function DecodeFieldsJSON

internal/models/fields_json.go:32–38  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 8

scalarFieldChangesFunction · 0.92
itemUpdatedSliceChangedFunction · 0.92
diffFieldsFunction · 0.92
reservedCarryViolationsFunction · 0.92
UnmarshalJSONMethod · 0.85
UnmarshalJSONMethod · 0.85

Calls 1

DecodeJSONKeepingNumbersFunction · 0.85