valyala / fastjson

Fast JSON parser and validator for Go. No custom structs, no code generation, no reflection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide more context in `Validate()`

grantstephens opened this issue · comments

It would be great to know the key of the value where the validation failed, i.e.

fastjson.Validate(`{"test":"bad
		json","good":"again"}`)

This gives

cannot parse JSON: cannot parse object: cannot parse object value: string cannot contain control char 0x0A; unparsed tail: ",\"good\":\"again\"}"

For big blobs it would be really handy to know that the key at which is failed was test, so the error might be something like

cannot parse JSON: cannot parse object: cannot parse object (test) value: string cannot contain control char 0x0A; unparsed tail: ",\"good\":\"again\"}"