MCPcopy Create free account
hub / github.com/pingcap/tidb / marshalTo

Method marshalTo

pkg/types/json_binary.go:156–180  ·  view source on GitHub ↗
(buf []byte)

Source from the content-addressed store, hash-verified

154}
155
156func (bj BinaryJSON) marshalTo(buf []byte) ([]byte, error) {
157 switch bj.TypeCode {
158 case JSONTypeCodeOpaque:
159 return jsonMarshalOpaqueTo(buf, bj.GetOpaque()), nil
160 case JSONTypeCodeString:
161 return jsonMarshalStringTo(buf, bj.GetString()), nil
162 case JSONTypeCodeLiteral:
163 return jsonMarshalLiteralTo(buf, bj.Value[0]), nil
164 case JSONTypeCodeInt64:
165 return strconv.AppendInt(buf, bj.GetInt64(), 10), nil
166 case JSONTypeCodeUint64:
167 return strconv.AppendUint(buf, bj.GetUint64(), 10), nil
168 case JSONTypeCodeFloat64:
169 return bj.marshalFloat64To(buf)
170 case JSONTypeCodeArray:
171 return bj.marshalArrayTo(buf)
172 case JSONTypeCodeObject:
173 return bj.marshalObjTo(buf)
174 case JSONTypeCodeDate, JSONTypeCodeDatetime, JSONTypeCodeTimestamp:
175 return jsonMarshalTimeTo(buf, bj.GetTime()), nil
176 case JSONTypeCodeDuration:
177 return jsonMarshalDurationTo(buf, bj.GetDuration()), nil
178 }
179 return buf, nil
180}
181
182// IsZero return a boolean indicate whether BinaryJSON is Zero
183func (bj BinaryJSON) IsZero() bool {

Callers 4

MarshalJSONMethod · 0.95
marshalArrayToMethod · 0.80
marshalObjToMethod · 0.80
TestBinaryJSONOpaqueFunction · 0.80

Calls 14

GetOpaqueMethod · 0.95
GetStringMethod · 0.95
GetInt64Method · 0.95
GetUint64Method · 0.95
marshalFloat64ToMethod · 0.95
marshalArrayToMethod · 0.95
marshalObjToMethod · 0.95
GetTimeMethod · 0.95
GetDurationMethod · 0.95
jsonMarshalOpaqueToFunction · 0.85
jsonMarshalStringToFunction · 0.85
jsonMarshalLiteralToFunction · 0.85

Tested by 1

TestBinaryJSONOpaqueFunction · 0.64