MCPcopy Create free account
hub / github.com/coder/coder / decodeNulInValue

Function decodeNulInValue

coderd/x/chatd/chatprompt/chatprompt.go:1716–1735  ·  view source on GitHub ↗

decodeNulInValue recursively walks a JSON value and applies decodeNulInString to every string, including map keys.

(v any)

Source from the content-addressed store, hash-verified

1714// decodeNulInValue recursively walks a JSON value and applies
1715// decodeNulInString to every string, including map keys.
1716func decodeNulInValue(v any) any {
1717 switch val := v.(type) {
1718 case string:
1719 return decodeNulInString(val)
1720 case map[string]any:
1721 out := make(map[string]any, len(val))
1722 for k, elem := range val {
1723 out[decodeNulInString(k)] = decodeNulInValue(elem)
1724 }
1725 return out
1726 case []any:
1727 out := make([]any, len(val))
1728 for i, elem := range val {
1729 out[i] = decodeNulInValue(elem)
1730 }
1731 return out
1732 default:
1733 return v
1734 }
1735}
1736
1737// encodeNulInJSON walks all string values (and keys) inside a
1738// json.RawMessage and applies encodeNulInString. Returns the

Callers 1

decodeNulInJSONFunction · 0.85

Calls 1

decodeNulInStringFunction · 0.85

Tested by

no test coverage detected