Skip to content
Advertisement

How to read value from JSON with Jackson Java

I have a JSON file:

JavaScript

I want to get the items separately. I try to do, but the result did null:

JavaScript

This is class for Items:

JavaScript

What I do wrong? how correctly read value from items?

Advertisement

Answer

You didn’t handle the JSON array – items – properly, so as I commented under OP, all what you need to do is to rename original class Items to Item and create another class Items as follows, and the Jackson library will do the rest for you:

JavaScript

Then you can deserialize the JSON string with your code snippet:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement