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

Method ReadString

lib/go/thrift/json_protocol.go:384–412  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

382}
383
384func (p *TJSONProtocol) ReadString(ctx context.Context) (string, error) {
385 var v string
386 if err := p.ParsePreValue(); err != nil {
387 return v, err
388 }
389 f, _ := p.reader.Peek(1)
390 if len(f) > 0 && f[0] == JSON_QUOTE {
391 p.reader.ReadByte()
392 value, err := p.ParseStringBody()
393 v = value
394 if err != nil {
395 return v, err
396 }
397 } else if len(f) > 0 && f[0] == JSON_NULL[0] {
398 b := make([]byte, len(JSON_NULL))
399 _, err := p.reader.Read(b)
400 if err != nil {
401 return v, NewTProtocolException(err)
402 }
403 if string(b) != string(JSON_NULL) {
404 e := fmt.Errorf("Expected a JSON string, found unquoted data started with %s", string(b))
405 return v, NewTProtocolExceptionWithType(INVALID_DATA, e)
406 }
407 } else {
408 e := fmt.Errorf("Expected a JSON string, found unquoted data started with %s", string(f))
409 return v, NewTProtocolExceptionWithType(INVALID_DATA, e)
410 }
411 return v, p.ParsePostValue()
412}
413
414func (p *TJSONProtocol) ReadBinary(ctx context.Context) ([]byte, error) {
415 var v []byte

Callers 5

ReadMessageBeginMethod · 0.95
ReadFieldBeginMethod · 0.95
ReadMapBeginMethod · 0.95
ParseElemListBeginMethod · 0.95

Calls 8

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

Tested by 1