FasterXML Jackson reports incorrect line number for JSON parsing errors

Solution Verified - Updated -

Issue

  • Parse errors report an earlier line / previous scope line number, for example

    {
        "userList" : [
            {
                user : "1"
            },
            {
                "user" : "2"
            }
        ]
    }
    

    Returns error:

    {"user":[{"user":"Unexpected character ('u' (code 117)): was expecting double-quote to start field name\n at [Source: (StringReader); line: 3, column: 9](through reference chain: hello.Users[\"userList\"]->java.util.ArrayList[0])"}]}
    

    Where the error is actually an line 4.

Environment

  • Red Hat JBoss Enterprise Application Platform (JBoss EAP) 7.1, 7.2
  • Jackson 2.9.10 or 2.8.9 (provided in JBoss EAP)
  • Syntactically invalid JSON code passed to parser

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content