ソースを参照

skip tab; add CurrentBuffer() to allow debug

Tao Wen 9 年 前
コミット
7a507e6bf3
1 ファイル変更10 行追加1 行削除
  1. 10 1
      jsoniter.go

+ 10 - 1
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 {