skipJSONSeparator advances offset past trailing JSON whitespace and at most one value separator (comma) in document, so the result points at the first byte of the next JSON token. The streaming decoder's InputOffset sits right after the most recently consumed token, which between values is the comm
(document string, offset int64)
| 195 | // regardless of position within the parent container, the returned offset always points at the |
| 196 | // first byte of the addressed token. |
| 197 | func skipJSONSeparator(document string, offset int64) int64 { |
| 198 | n := int64(len(document)) |
| 199 | for offset < n && isJSONWhitespace(document[offset]) { |
| 200 | offset++ |
| 201 | } |
| 202 | if offset < n && document[offset] == ',' { |
| 203 | offset++ |
| 204 | } |
| 205 | for offset < n && isJSONWhitespace(document[offset]) { |
| 206 | offset++ |
| 207 | } |
| 208 | return offset |
| 209 | } |
| 210 | |
| 211 | func isJSONWhitespace(c byte) bool { |
| 212 | return c == ' ' || c == '\t' || c == '\n' || c == '\r' |
no test coverage detected
searching dependent graphs…