| 382 | } |
| 383 | |
| 384 | func (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 | |
| 414 | func (p *TJSONProtocol) ReadBinary(ctx context.Context) ([]byte, error) { |
| 415 | var v []byte |