MCPcopy Create free account
hub / github.com/apache/thrift / ReadBinary

Method ReadBinary

lib/go/thrift/simple_json_protocol.go:571–600  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

569}
570
571func (p *TSimpleJSONProtocol) ReadBinary(ctx context.Context) ([]byte, error) {
572 var v []byte
573 if err := p.ParsePreValue(); err != nil {
574 return nil, err
575 }
576 f, _ := p.reader.Peek(1)
577 if len(f) > 0 && f[0] == JSON_QUOTE {
578 p.reader.ReadByte()
579 value, err := p.ParseBase64EncodedBody()
580 v = value
581 if err != nil {
582 return v, err
583 }
584 } else if len(f) > 0 && f[0] == JSON_NULL[0] {
585 b := make([]byte, len(JSON_NULL))
586 _, err := p.reader.Read(b)
587 if err != nil {
588 return v, NewTProtocolException(err)
589 }
590 if string(b) != string(JSON_NULL) {
591 e := fmt.Errorf("Expected a JSON string, found unquoted data started with %s", string(b))
592 return v, NewTProtocolExceptionWithType(INVALID_DATA, e)
593 }
594 } else {
595 e := fmt.Errorf("Expected a JSON string, found unquoted data started with %s", string(f))
596 return v, NewTProtocolExceptionWithType(INVALID_DATA, e)
597 }
598
599 return v, p.ParsePostValue()
600}
601
602func (p *TSimpleJSONProtocol) ReadUUID(ctx context.Context) (v Tuuid, err error) {
603 var s string

Calls 8

ParsePreValueMethod · 0.95
ParsePostValueMethod · 0.95
NewTProtocolExceptionFunction · 0.85
stringFunction · 0.85
ReadByteMethod · 0.65
ReadMethod · 0.65