MCPcopy
hub / github.com/github/github-mcp-server / sortJSONKeys

Function sortJSONKeys

internal/toolsnaps/toolsnaps.go:94–101  ·  view source on GitHub ↗

sortJSONKeys recursively sorts all object keys in a JSON byte array by unmarshaling to map[string]any and remarshaling. Go's JSON encoder automatically sorts map keys alphabetically.

(jsonData []byte)

Source from the content-addressed store, hash-verified

92// unmarshaling to map[string]any and remarshaling. Go's JSON encoder
93// automatically sorts map keys alphabetically.
94func sortJSONKeys(jsonData []byte) ([]byte, error) {
95 var data any
96 if err := json.Unmarshal(jsonData, &data); err != nil {
97 return nil, err
98 }
99
100 return json.MarshalIndent(data, "", " ")
101}

Callers 3

writeSnapFunction · 0.85
TestSortJSONKeysFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestSortJSONKeysFunction · 0.68