0

How can I deserialize only the items array?

{
 "code": 200,
 "bookmarks": {
   "count": 2,
   "items": [
     {
       "status": "I",
       "id": "1",
       "percent": 9,
       "timestamp": 1462826317475
     },
     {
       "status": "I",
       "id": "2",
       "percent": 10,
       "timestamp": 1462909994981
     }
   ],
   "links": []
  }
}

I know for an array I can do something like this:

List<MyClass> myObjects = mapper.readValue(jsonInput, new TypeReference<List<MyClass>>(){});

Can I specify only deserializing items?

1 Answer 1

1

Use ObjectReaders at(JsonPointer) method to specify sub-tree to bind. Something like:

Item[] items = mapper.readerFor(Item[].class).at("/bookmarks/items").readValue();
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.