Hi folks,

I was wondering if there is support for exporting the offset method of the 
encoding/json Decoder? The offset would be useful in cases where an error 
is reported during decoding. The json.SyntaxError and 
json.UnmarshalTypeError types export an Offset field but for other error 
types it's currently not possible to reconstruct the offset. This is most 
notable when I'm providing an implementation for the Unmarshaler interface. 
When decoder.Decode() returns an error generated by an UnmarshalJSON 
implementation, it's not possible to reconstruct the offset. If the offset 
method was public then I could use that information to show where the error 
occurred. There is a slight wrinkle in that the Decoder offset is set to 
the end of a token when an error occurs. But I don't think it's an issue. 
If I store the length of the token in the error that is returned from the 
UnmarshalJSON method then I can subtract and find the start of the token. I 
think that's a fair design as it doesn't require any changes to the 
Decoder. Is there any interest in exporting this method?

Thanks,
--Michael

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to