Not the duplicate of How to use Jackson to deserialise an array of objects.
Here in the list ,items are string within double quotes.
I am trying to convert a list of messages which are jsonString to List of UserDefined objects. I have input like this.
[
"{\"id\":\"5\",\"type\":\"abc\",\"innerObject\":{\"id\":\"8\"}}"
]
What is the method to convert this list to List of MyClass.
class MyClass{
String id;
String type;
Inner inner;
//getters and setters
}
class Inner{
String id;
//getters and setters
}
I have tried
objectMapper.readValue(jsonFormattedString, new TypeReference<List<MyClass>>(){});
Also this
Type listType = new TypeToken<ArrayList<MyClass>>() {}.getType();
myList = new Gson().fromJson(jsonFormattedString, listType);
But not working.
Expected output is
[{"id":"5","type":"abc","innerObject":"8"}]