encoding/json: add offset to the reported errors #9693
Closed
Labels
Comments
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Sometimes JSON data can be inconsistent (Ex: bad APIs). One field can be string in one row, in another float64. It would help to figure out what field is responsible if there was at least the
offset
from the JSON file associated with the reported error.Example:
Suppose there is a data.json file that contains 10k rows and row 1230 has field HSigma a float64 instead of string. The error reported when unmarshalling would be:
json: cannot unmarshal string into Go value of type float64
Which is not very useful since we have a few string fields and we don't know the row. Instead something like this would tell me where I should look in my json file:
json: cannot unmarshal 'string' into Go value of type 'float64' offset 7427
The text was updated successfully, but these errors were encountered: