본문 바로가기

Android

How to use Jackson to deserialise an array of objects

As Array:
[code]MyClass[] myObjects = mapper.readValue(json, MyClass[].class);[/code]

As List:
[code]List<MyClass> myObjects = mapper.readValue(jsonInput, new TypeReference<List<MyClass>>(){});[/code]

Another way to specify the List type:
[code]List<MyClass> myObjects = mapper.readValue(jsonInput, mapper.getTypeFactory().constructCollectionType(List.class, MyClass.class));[/code]

'Android' 카테고리의 다른 글

How can I get the cookies from HttpClient?  (0) 2013.11.01
animation object animator  (0) 2013.10.31
Endless Scrolling ListView in Android  (0) 2013.10.31
EditText / TextView 속성 [출처] EditText / TextView 속성  (0) 2013.10.16
@TargetApi  (0) 2013.10.10