Skip to content
Advertisement

Deserializing JSON in Java using Jackson

I have the following sample fragment of JSON I am trying to deserialize.

JavaScript

I can deserialize the data up to id and key, but cannot deserialize attachments that is in fields. My attachment class is always null

Here’s my code.

Response.java

JavaScript

Issue.java

JavaScript

Fields.java

JavaScript

Attachments.java

JavaScript

Attachments.java

JavaScript

Advertisement

Answer

Think of each variable in your Java classes as corresponding to an attribute in the JSON. “Attachments” is not in the JSON file. You should be able to remove it and change the variable definition in the Fields class.

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