I want to map following JSON struct to a POJO class automatically:
{
"fieldClass":
{
"a": 1,
"b": "b",
"c": "c",
"d": "d",
"e": "e"
}
}
I added the parameter to map JSON to POJO class to web.xml. Also I tried to define two class, one for wrapper class and one for inside class. But following exception is thrown when I tried to use some method:
SEVERE: Servlet.service() for servlet [Jersey REST Service] in context with path [/projectName] threw exception [org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field “fieldClass” (Class className), not marked as ignorable
at [Source: org.apache.catalina.connector.CoyoteInputStream@4d5d6704; line: 1, column: 10] (through reference chain: className[“fieldClass”])] with root cause
Can I map this to Java classes automatically?
Have a look at this section: JSON.org Java section
Also Jackson Quickstart guide