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

Method ReadString

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

Source from the content-addressed store, hash-verified

539}
540
541func (p *TSimpleJSONProtocol) ReadString(ctx context.Context) (string, error) {
542 var v string
543 if err := p.ParsePreValue(); err != nil {
544 return v, err
545 }
546 f, _ := p.reader.Peek(1)
547 if len(f) > 0 && f[0] == JSON_QUOTE {
548 p.reader.ReadByte()
549 value, err := p.ParseStringBody()
550 v = value
551 if err != nil {
552 return v, err
553 }
554 } else if len(f) > 0 && f[0] == JSON_NULL[0] {
555 b := make([]byte, len(JSON_NULL))
556 _, err := p.reader.Read(b)
557 if err != nil {
558 return v, NewTProtocolException(err)
559 }
560 if string(b) != string(JSON_NULL) {
561 e := fmt.Errorf("Expected a JSON string, found unquoted data started with %s", string(b))
562 return v, NewTProtocolExceptionWithType(INVALID_DATA, e)
563 }
564 } else {
565 e := fmt.Errorf("Expected a JSON string, found unquoted data started with %s", string(f))
566 return v, NewTProtocolExceptionWithType(INVALID_DATA, e)
567 }
568 return v, p.ParsePostValue()
569}
570
571func (p *TSimpleJSONProtocol) ReadBinary(ctx context.Context) ([]byte, error) {
572 var v []byte

Callers 4

ReadMessageBeginMethod · 0.95
ReadUUIDMethod · 0.95

Calls 8

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