MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / EncodeJSONKeyStringAscending

Function EncodeJSONKeyStringAscending

pkg/util/encoding/encoding.go:714–721  ·  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

712// while at the same time giving us a sentinel to identify JSON keys. The end parameter is used
713// to determine if this is the last key in a a JSON path. If it is we don't add a separator after it.
714func EncodeJSONKeyStringAscending(b []byte, s string, end bool) []byte {
715 str := UnsafeConvertStringToBytes(s)
716
717 if end {
718 return encodeBytesAscendingWithoutTerminatorOrPrefix(b, str)
719 }
720 return encodeBytesAscendingWithTerminator(b, str, escapedJSONObjectKeyTerm)
721}
722
723// EncodeJSONEmptyArray returns a byte array b with a byte to signify an empty JSON array.
724func EncodeJSONEmptyArray(b []byte) []byte {

Callers 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…