mholt / json-to-go

Translates JSON into a Go type in your browser instantly (original)
https://mholt.github.io/json-to-go/
MIT License
4.48k stars 473 forks source link

Elaborate on the error [feature suggestion] #115

Open petric3 opened 2 years ago

petric3 commented 2 years ago

I'm getting pretty long streamed json messages of different struct. Errors like the following one happens quite often. image

It's quite clear that there's redundant/empty space but it's very hard to locate it at the given position. Is it possible to elaborate on the error's position, e.g. if empty space, then give extra say 10 before and after characters to be easier searched for, or even better to jump to that position where the error is. Thank you for consideration.

mholt commented 2 years ago

Thanks for the request. It's a good idea, but I don't generate the error message. I'm not sure if it has a particular structure or if it's just a string. If it's just a string then getting its position would be a bit hacky and inelegant. But if we could then maybe we could augment the error message ourselves to display surrounding text.