}
if !dec.tokenValueAllowed() {
- return &SyntaxError{msg: "not at beginning of value", Offset: dec.offset()}
+ return &SyntaxError{msg: "not at beginning of value", Offset: dec.InputOffset()}
}
// Read whole value into buffer.
return err
}
if c != ',' {
- return &SyntaxError{"expected comma after array element", dec.offset()}
+ return &SyntaxError{"expected comma after array element", dec.InputOffset()}
}
dec.scanp++
dec.tokenState = tokenArrayValue
return err
}
if c != ':' {
- return &SyntaxError{"expected colon after object key", dec.offset()}
+ return &SyntaxError{"expected colon after object key", dec.InputOffset()}
}
dec.scanp++
dec.tokenState = tokenObjectValue
case tokenObjectComma:
context = " after object key:value pair"
}
- return nil, &SyntaxError{"invalid character " + quoteChar(c) + context, dec.offset()}
+ return nil, &SyntaxError{"invalid character " + quoteChar(c) + context, dec.InputOffset()}
}
// More reports whether there is another element in the
}
}
-func (dec *Decoder) offset() int64 {
+// InputOffset returns the input stream byte offset of the current decoder position.
+// The offset gives the location of the end of the most recently returned token
+// and the beginning of the next token.
+func (dec *Decoder) InputOffset() int64 {
return dec.scanned + int64(dec.scanp)
}