tidwall / gjson

Get JSON values quickly - JSON parser for Go
MIT License
13.95k stars 841 forks source link

Issue in parsing invalid escape character #281

Open Tr1nket opened 2 years ago

Tr1nket commented 2 years ago

I believe there is an issue with the parser of JSON. When sent example JSON like {"test":"1","message":{"example":"1","json_content":"{\"blocks\":[{\"text\":\"hello\ \",\"data_to_be_truncated\":\"here\"}","test2":"2","links":[]}}

The text after hello\ \" will be truncated for json_content which causes errors in parsing inner JSON. Other libraries flag this as improper JSON and return an empty struct while GJSON will return

test: 1,
message {
   example: 1,
   json_content: "{\"blocks\":[{\"text\":\"hello",
   test2: 2,
   links: []
   }

without error. Please let me know if you need further details.