Handling "Unrecognized token" exception in custom json with Jackson

Content you list is unfortunately not valid JSON, so what you have is not really a JSON document, but perhaps serialization of a Javascript object. All String values MUST be enclosed in double quotes in JSON.

Jackson does not support reading of such content directly, but it may be possible to read this using YAML parser like SnakeYAML. Jackson also has YAML data format module at https://github.com/FasterXML/jackson-dataformat-yaml/ so you could perhaps use that. Given that YAML is (mostly!) a superset of JSON, it could probably do what you want.


The handler is not called because the invalid part is not the property ("two") but the value (nonStandardThing()).

An obvious way to handle this, is to pass nonStandardThing() as a String, i.e. rewrite the JSON document as

{
    "test": {
        "one":"oneThing",
        "two": "nonStandardThing()",
        "three": true
    }
}

If that is not a possibility, there is not much to do. Using a custom Jackson Deserializer is only useful for properties, not values.