JacksonUtils readTree not parsing properly

Viewed 333

In a JAX_RS server endpoint, a service is supposed properly parse this:

{"user_id":"ngerrie"}

into a JsonNode that can be properly rendered on return.

String sampleRole="{\"user_id\":\"vespasian\"}"
List result = new List<Object>
result.add(new ObjectMapper().readTree(sampleRole));

The return takes the object and serializes it with

return Response.ok(result,MediaType.APPLICATION_JSON).build();

Instead of getting {"user_id": "ngerrie"}, it returns this:

            {
                "array": false,
                "bigDecimal": false,
                "bigInteger": false,
                "binary": false,
                "boolean": false,
                "containerNode": true,
                "double": false,
                "float": false,
                "floatingPointNumber": false,
                "int": false,
                "integralNumber": false,
                "long": false,
                "missingNode": false,
                "null": false,
                "number": false,
                "object": true,
                "pojo": false,
                "short": false,
                "textual": false,
                "valueNode": false,
                "nodeType": "OBJECT"
            }

The class is com.fasterxml.jackson.databind.ObjectMapper g:com.fasterxml.jackson.core a:data-bind v:2.8.7

These change started happening after an upgrade.

1 Answers

I never knew what caused this specific error, but I ended up reverting my branch, creating a brand new Eclipse workspace and Tomcat server instance. As near as I can tell, the version I was using was the same used when the code worked. But alas, somehow, it just became easier to burn it down and recreate it. If I had to guess, @Mormegil was probably not incorrect.

Related