mirror of
https://github.com/json-iterator/go.git
synced 2025-04-17 11:26:35 +02:00
skip tab; add CurrentBuffer() to allow debug
This commit is contained in:
parent
7d8dcb7ec4
commit
7a507e6bf3
11
jsoniter.go
11
jsoniter.go
@ -43,7 +43,7 @@ func ParseString(input string) *Iterator {
|
|||||||
|
|
||||||
func (iter *Iterator) skipWhitespaces() {
|
func (iter *Iterator) skipWhitespaces() {
|
||||||
c := iter.readByte()
|
c := iter.readByte()
|
||||||
for c == ' ' || c == '\n' {
|
for c == ' ' || c == '\n' || c == '\t' {
|
||||||
c = iter.readByte()
|
c = iter.readByte()
|
||||||
}
|
}
|
||||||
iter.unreadByte()
|
iter.unreadByte()
|
||||||
@ -58,6 +58,15 @@ func (iter *Iterator) ReportError(operation string, msg string) {
|
|||||||
string(iter.buf[peekStart: iter.head]), string(iter.buf[0:iter.tail]))
|
string(iter.buf[peekStart: iter.head]), string(iter.buf[0:iter.tail]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) CurrentBuffer() string {
|
||||||
|
peekStart := iter.head - 10
|
||||||
|
if peekStart < 0 {
|
||||||
|
peekStart = 0
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("parsing %v ...%s... at %s", iter.head,
|
||||||
|
string(iter.buf[peekStart: iter.head]), string(iter.buf[0:iter.tail]))
|
||||||
|
}
|
||||||
|
|
||||||
func (iter *Iterator) readByte() (ret byte) {
|
func (iter *Iterator) readByte() (ret byte) {
|
||||||
if iter.head == iter.tail {
|
if iter.head == iter.tail {
|
||||||
if iter.reader == nil {
|
if iter.reader == nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user