Unexpected character ('}' (code 125))

Jackson quotes the character and its decimal code point, then says what it wanted instead. The second half of the message is the useful half: "was expecting double-quote to start field name" means it was waiting for the next key, which is what a trailing comma promises and does not deliver.

How the message appears

Jackson wording. The number in brackets is the decimal code point of the character it found, which is what makes these messages searchable but unreadable.

  • com.fasterxml.jackson.core.JsonParseException: Unexpected character ('}' (code 125)): was expecting double-quote to start field name
  • Unexpected character ('<' (code 60)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')

What causes it

(code 125) — a trailing comma before a closing brace

The comma said another member was coming; the closing brace arrived instead. Jackson reports the brace, so the message points one line past the comma that caused it.

(code 93) — a trailing comma inside an array

The same mistake inside an array. 93 is ].

(code 60) — the document is HTML

60 is <. An error page, a login redirect or a proxy response. No change to the JSON will help, because there is no JSON.

(code 39) — single quotes

39 is '. Valid in JavaScript and Python source, never in JSON.

The fix

Delete the comma before the closing } or ]. JSON permits a comma only between two values, never after the last one — which is exactly where a code generator or a hand edit tends to leave one.

Fails to parse
{
  "id": 7,
  "tags": ["a", "b"],
}
Parses
{
  "id": 7,
  "tags": ["a", "b"]
}

The example travels in the URL fragment, which browsers never send to a server.

Worth knowing

  • A quick decode of the codes you will actually see: 123 {, 125 }, 91 [, 93 ], 44 ,, 58 :, 34 ", 39 ', 60 <, 10 newline.
  • A very low code such as (code 0) or (code 1) means you are parsing binary or a mis-decoded charset — check for a gzipped body being read as text, or a byte order mark.

Your JSON and text are processed entirely in your browser and are never sent anywhere. To understand how the site is used we record each page view — the page, the referrer and an approximate location from your IP address — and keep it for 90 days. Nothing is stored on your device unless you choose it. Accept to also store a device identifier here and record your browser and device characteristics, which is what lets a return visit be told from a new one. Decline and nothing is sent at all. We respect Do Not Track. See our privacy policy.