Unexpected token in JSON - Hmmm
Received error
An invalid JSON is sent in the request.body, error: please ensure that you have wrapped all JSON property names in quotes. details: Unexpected token in JSON at position 592
Turns out the offending string was
"address2": "FedEx Account # 370000740 \t BU#16051",
But there is nothing wrong with that string, it's valid JSON, ugly and bad practice to store that data there, but valid JSON.
From the IETF specification:
The representation of strings is similar to conventions used in the C
family of programming languages. A string begins and ends with
quotation marks. All Unicode characters may be placed within the
quotation marks, except for the characters that must be escaped:
quotation mark, reverse solidus, and the control characters (U+0000
through U+001F).
It goes on to enumerate the characters required to be escaped:
char = unescaped /
escape (
%x22 / ; " quotation mark U+0022
%x5C / ; \ reverse solidus U+005C
%x2F / ; / solidus U+002F
%x62 / ; b backspace U+0008
%x66 / ; f form feed U+000C
%x6E / ; n line feed U+000A
%x72 / ; r carriage return U+000D
%x74 / ; t tab U+0009
%x75 4HEXDIG ) ; uXXXX U+XXXX
So, seems like an incorrect error.
I also wanted to mention that reporting the position is better than nothing, but the reported position doesn't correspond to the 'pretty' JSON we see in the UI. I tried various minification techniques to try to zero in on "position 592" but could never get right to it. A nice enhancement would be to bracket the offending position and show a substring excerpt, like 20 characters before and after the offending position. Just an idea.
Comments
Please sign in to leave a comment.