• Register
0 votes

Problem :

I am trying to convert the certain JSON string to the Java object. I am trying to use  Jackson for JSON handling. I have totally  no control over the input JSON I am reading it from a web service.

Below is my input JSON:


Below is my simplified use case:

private void tryToRead() {

String jsonString = "{\"wrapper\"\:[{\"id\":\"09\",\"name\":\"Fred\"}]}";

    ObjectMapper objmapper = new ObjectMapper(); 

    Wrapper wrapp = null;

    try {

        wrapp = mapper.readValue(jsonString , Wrapper.class);

    } catch (Exception exc) {



    System.out.println("wrapper = " + wrapp);


Below is my entity class :

public Class MyStudent {

    private String name;

    private String id;

    //getters & setters for the  name & id here


Below is my MyWrapper class is basically the container object to get the list of students:

public Class MyWrapper {

    private List<MyStudent> mystudents;

    //getters & setters here


But I keep on getting below error and "wrapper" returns null.

Have anyone faced the same issue before?


Unrecognized field "wrapper" (Class MyWrapper), not marked as ignorable

at [Source: java.io.StringReader@1198891; line: 1, column: 23]

(through reference chain: MyWrapper["wrapper"])

at org.codehaus.jackson.map.exc.UnrecognizedPropertyException


6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

Please use the below code :

ObjectMapper myObjectMapper = getMyObjectMapper();
myObjectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

It will ignore all the properties that you have not declared.

9 7 4
38,600 points

Related questions

0 votes
1 answer 481 views
Problem : I am very new to Spring Boot. I am learning to write code in Spring Boot. I have written my first Spring Boot code as below @RequestMapping(value = "/bar/foo", method = RequestMethod.GET) public MyResponseEntity<foo> foo() { Foo model; ... return ... .core</groupId> <artifactId>jackson-databind</artifactId> <version>2.4.3</version> </dependency> How can I fix above Spring Boot exception?
asked Feb 29, 2020 mphil 2.3k points
0 votes
1 answer 293 views
Problem : I want to POST the List of custom objects. My JSON in a request body is as below : {     "collection": [         {             "name": "Test ordert1",             "detail": "ahk ksa"         },         {             "name": "Test ... } But I am facing below error: &ldquo;Can not deserialize instance of java.util.arraylist out of start_object token&rdquo; How can I fix the above error?
asked Jan 21, 2020 jwilliam 3.9k points
0 votes
1 answer 4.7K views
Problem : I am trying to POST a List of custom objects but i am getting exception as below can not deserialize instance of java.util.arraylist out of start_object token
asked Oct 22, 2019 peterlaw 6.9k points
0 votes
1 answer 63 views
Problem : According to the following documents: https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-user_timeline.html I have the oauth user token and the user token secret, plus I have my app credentials... The docs state that the ... is supported by Twitter, but how should I include it in the get requests for screen names those are not publicly accessible?
asked Nov 25, 2019 alecxe 7.5k points
0 votes
1 answer 7 views
I want to know how to pass data from child component to its parent in ReactJS? Here is my child component: export const SelectLanguage = React.createClass({ getInitialState: function(){ return{ selectedCode: '', selectedLanguage: '', }; }, handleLangChange: function (e) { ... you have any idea what I&rsquo;m doing wrong? Please never mind the json file as it has nothing to do with the problem.
asked Jan 14 khaled 280 points
0 votes
1 answer 25 views
1 vote
1 answer 97 views
Problem: I have fundamental knowledge about Asp.net and Mysql. I have written code in Asp.net. Now I am facing below error if I try to connect to mysql database to the editor. Fill: selectcommand.connection property has not been initialized. Please find below my code ... server" Text="Button" OnClick="MyButton1_Click" /> </form> I need to fix above error please guide me in fixing it for me.
asked Jun 2, 2020 Martin K 6.6k points
0 votes
1 answer 11 views
Hello all! I&rsquo;m newbie programmer. Currently I&rsquo;m working with jSON to fetch some data for my new project.But I&rsquo;ve stucked with some problems. I&rsquo;m trying using getJSON method to get value of it. Need help. Any help will be appreciated. What I want to get is jobDescription&rsquo;s value. {"JobData":{"JobDescription":"Cashier Wanted","JobSearch":"Search"}}
asked Oct 27, 2020 mrain 120 points