| 539 | } |
| 540 | |
| 541 | func (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 | |
| 571 | func (p *TSimpleJSONProtocol) ReadBinary(ctx context.Context) ([]byte, error) { |
| 572 | var v []byte |