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

Function newEncoded

pkg/util/json/encoded.go:120–154  ·  view source on GitHub ↗
(e jEntry, v []byte)

Source from the content-addressed store, hash-verified

118}
119
120func newEncoded(e jEntry, v []byte) (JSON, error) {
121 var typ Type
122 var containerLen int
123 switch e.typCode {
124 case stringTag:
125 typ = StringJSONType
126 case numberTag:
127 typ = NumberJSONType
128 case nullTag: // Don't bother with returning a jsonEncoded for the singleton types.
129 return NullJSONValue, nil
130 case falseTag:
131 return FalseJSONValue, nil
132 case trueTag:
133 return TrueJSONValue, nil
134 case containerTag:
135 // Every container is prefixed with its uint32 container header.
136 containerHeader, err := getUint32At(v, 0)
137 if err != nil {
138 return nil, err
139 }
140 switch containerHeader & containerHeaderTypeMask {
141 case arrayContainerTag:
142 typ = ArrayJSONType
143 case objectContainerTag:
144 typ = ObjectJSONType
145 }
146 containerLen = int(containerHeader & containerHeaderLenMask)
147 }
148
149 return &jsonEncoded{
150 typ: typ,
151 containerLen: containerLen,
152 value: v,
153 }, nil
154}
155
156func getUint32At(v []byte, idx int) (uint32, error) {
157 if idx+4 > len(v) {

Callers 4

objectNthValueMethod · 0.85
FetchValIdxMethod · 0.85
shallowDecodeMethod · 0.85
ExistsMethod · 0.85

Calls 1

getUint32AtFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…