Peek looks ahead and returns the next token kind without advancing a read.
()
| 57 | |
| 58 | // Peek looks ahead and returns the next token kind without advancing a read. |
| 59 | func (d *Decoder) Peek() (Token, error) { |
| 60 | defer func() { d.lastCall = peekCall }() |
| 61 | if d.lastCall == readCall { |
| 62 | d.lastToken, d.lastErr = d.Read() |
| 63 | } |
| 64 | return d.lastToken, d.lastErr |
| 65 | } |
| 66 | |
| 67 | // Read returns the next JSON token. |
| 68 | // It will return an error if there is no valid token. |