MCPcopy Index your code
hub / github.com/pingcap/tidb / ParseBinaryJSONFromString

Function ParseBinaryJSONFromString

pkg/types/json_binary.go:507–521  ·  view source on GitHub ↗

ParseBinaryJSONFromString parses a json from string.

(s string)

Source from the content-addressed store, hash-verified

505
506// ParseBinaryJSONFromString parses a json from string.
507func ParseBinaryJSONFromString(s string) (bj BinaryJSON, err error) {
508 if len(s) == 0 {
509 err = ErrInvalidJSONText.GenWithStackByArgs("The document is empty")
510 return
511 }
512 data := hack.Slice(s)
513 if !json.Valid(data) {
514 err = ErrInvalidJSONText.GenWithStackByArgs("The document root must not be followed by other values.")
515 return
516 }
517 if err = bj.UnmarshalJSON(data); err != nil && !ErrJSONObjectKeyTooLong.Equal(err) && !ErrJSONDocumentTooDeep.Equal(err) {
518 err = ErrInvalidJSONText.GenWithStackByArgs(err)
519 }
520 return
521}
522
523// UnmarshalJSON implements the json.Unmarshaler interface.
524func (bj *BinaryJSON) UnmarshalJSON(data []byte) error {

Callers 15

TestJSONExtractFunction · 0.92
TestJSONSetInsertReplaceFunction · 0.92
TestJSONMergeFunction · 0.92
TestJSONMergePreserveFunction · 0.92
TestJSONArrayFunction · 0.92
TestJSONObjectFunction · 0.92
TestJSONRemoveFunction · 0.92
TestJSONKeysFunction · 0.92
TestJSONArrayAppendFunction · 0.92
TestJSONSearchFunction · 0.92
TestJSONArrayInsertFunction · 0.92
TestJSONMergePatchFunction · 0.92

Calls 4

SliceFunction · 0.92
ValidMethod · 0.65
EqualMethod · 0.65
UnmarshalJSONMethod · 0.45

Tested by 15

TestJSONExtractFunction · 0.74
TestJSONSetInsertReplaceFunction · 0.74
TestJSONMergeFunction · 0.74
TestJSONMergePreserveFunction · 0.74
TestJSONArrayFunction · 0.74
TestJSONObjectFunction · 0.74
TestJSONRemoveFunction · 0.74
TestJSONKeysFunction · 0.74
TestJSONArrayAppendFunction · 0.74
TestJSONSearchFunction · 0.74
TestJSONArrayInsertFunction · 0.74
TestJSONMergePatchFunction · 0.74