MCPcopy Create free account
hub / github.com/dolthub/doltgresql / EncodeJSONKeyStringAscending

Function EncodeJSONKeyStringAscending

postgres/parser/encoding/encoding.go:489–496  ·  view source on GitHub ↗

EncodeJSONKeyStringAscending encodes the JSON key string value with a JSON specific escaped terminator. This allows us to encode keys in the same number of bytes as a string, while at the same time giving us a sentinel to identify JSON keys. The end parameter is used to determine if this is the last

(b []byte, s string, end bool)

Source from the content-addressed store, hash-verified

487// while at the same time giving us a sentinel to identify JSON keys. The end parameter is used
488// to determine if this is the last key in a a JSON path. If it is we don't add a separator after it.
489func EncodeJSONKeyStringAscending(b []byte, s string, end bool) []byte {
490 str := UnsafeConvertStringToBytes(s)
491
492 if end {
493 return encodeBytesAscendingWithoutTerminatorOrPrefix(b, str)
494 }
495 return encodeBytesAscendingWithTerminator(b, str, escapedJSONObjectKeyTerm)
496}
497
498// EncodeJSONEmptyArray returns a byte array b with a byte to signify an empty JSON array.
499func EncodeJSONEmptyArray(b []byte) []byte {

Callers 1

Tested by

no test coverage detected