Reset erases the state of t and re-initializes it with the json input from b.
(b []byte)
| 81 | |
| 82 | // Reset erases the state of t and re-initializes it with the json input from b. |
| 83 | func (t *Tokenizer) Reset(b []byte) { |
| 84 | if t.stack != nil { |
| 85 | releaseStack(t.stack) |
| 86 | } |
| 87 | // This code is similar to: |
| 88 | // |
| 89 | // *t = Tokenizer{json: b} |
| 90 | // |
| 91 | // However, it does not compile down to an invocation of duff-copy. |
| 92 | t.Delim = 0 |
| 93 | t.Value = nil |
| 94 | t.Err = nil |
| 95 | t.Depth = 0 |
| 96 | t.Index = 0 |
| 97 | t.IsKey = false |
| 98 | t.isKey = false |
| 99 | t.json = b |
| 100 | t.stack = nil |
| 101 | t.decoder = decoder{flags: internalParseFlags(b)} |
| 102 | } |
| 103 | |
| 104 | // Next returns a new tokenizer pointing at the next token, or the zero-value of |
| 105 | // Tokenizer if the end of the json input has been reached. |