From 7a507e6bf33e8e36f3e8c15f2c49e605b8f5087a Mon Sep 17 00:00:00 2001 From: Tao Wen Date: Mon, 5 Dec 2016 10:43:42 +0800 Subject: [PATCH] skip tab; add CurrentBuffer() to allow debug --- jsoniter.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/jsoniter.go b/jsoniter.go index 59c9d95..c137819 100644 --- a/jsoniter.go +++ b/jsoniter.go @@ -43,7 +43,7 @@ func ParseString(input string) *Iterator { func (iter *Iterator) skipWhitespaces() { c := iter.readByte() - for c == ' ' || c == '\n' { + for c == ' ' || c == '\n' || c == '\t' { c = iter.readByte() } 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])) } +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) { if iter.head == iter.tail { if iter.reader == nil {