Skip to content
Advertisement

How can I deserialize it using Java?

I have a postgresql function that returns json:

JavaScript

How can I deserialize it using Java?

My POJO

JavaScript

I want to use ObjectMapper but I can’t do this)

Advertisement

Answer

Change your Information class to the following (mind the Jackson annotations to match JSON properties):

JavaScript

And then you just need to use Jackson’s ObjectMapper to convert your JSON String to the corresponding objects as follows:

JavaScript

I have doubts regarding Integer age;, because in your JSON it is represented as a String, so I am not entirely sure that Jackson is able to do the convertion. If it is not you will need to either change the property to String age; or create a custom deserializer for User class.

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