Unexpected character ('}' (code 125))

Jackson gives you the character it found, its decimal code, and then what it wanted instead. Read the second half first. "was expecting double-quote to start field name" means it was waiting for the next key, which is exactly what a trailing comma promises and never delivers.

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')

The fix

Delete the comma before the closing } or ]. A comma goes between two values and 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.

What causes it

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

The comma said another key was coming and the closing brace turned up 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, one level in. 93 is ].

(code 60): the document is HTML

60 is <. You have an error page, a login redirect or a proxy response. No amount of editing the JSON will help, because there is no JSON.

(code 39): single quotes

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

Worth knowing

  • The codes you will actually run into: 123 {, 125 }, 91 [, 93 ], 44 ,, 58 :, 34 ", 39 ', 60 <, 10 newline.
  • A very low code like (code 0) or (code 1) means you are parsing binary, or text that was decoded with the wrong charset. Look for a gzipped body being read as text, or a byte order mark.

Written by Vishnu Shankar.

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.