MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / sortJSON

Function sortJSON

testutil/json.go:125–139  ·  view source on GitHub ↗

sortJSON looks for any arrays in the unmarshalled JSON and sorts them in an arbitrary but deterministic order based on their content.

(i interface{})

Source from the content-addressed store, hash-verified

123// sortJSON looks for any arrays in the unmarshalled JSON and sorts them in an
124// arbitrary but deterministic order based on their content.
125func sortJSON(i interface{}) uint64 {
126 if i == nil {
127 return 0
128 }
129 switch i := i.(type) {
130 case map[string]interface{}:
131 return sortJSONMap(i)
132 case []interface{}:
133 return sortJSONArray(i)
134 default:
135 h := crc64.New(crc64.MakeTable(crc64.ISO))
136 fmt.Fprint(h, i)
137 return h.Sum64()
138 }
139}
140
141func sortJSONMap(m map[string]interface{}) uint64 {
142 var h uint64

Callers 3

DiffJSONMapsFunction · 0.70
sortJSONMapFunction · 0.70
sortJSONArrayFunction · 0.70

Calls 2

sortJSONMapFunction · 0.70
sortJSONArrayFunction · 0.70

Tested by

no test coverage detected