Building a POJO to parse this JSON using Jackson
I'm working with Jackson for JSON serialization. Normally the structures I get back are named and are pretty easy to deal with, yet I've run into one I can't quite get a POJO built for that will work. Any suggestions on how to parse the following into a set POJOs?
JSON:
[
{
"transaction":
{
"accountType":"type",
"action":"A",
"created_at":"2011-08-16T17:41:48Z",
"id":1,
"sbAccountId":5,
"updated_at":"2011-08-16T17:41:48Z",
"userId":"1234",
"userName":"userName"
}
},
{
"transactio开发者_如何学编程n":
{
"accountType":"type",
"action":"A",
"created_at":"2011-08-16T17:41:48Z",
"id":1,
"sbAccountId":5,
"updated_at":"2011-08-16T17:41:48Z",
"userId":"1234",
"userName":"userName"
}
}
]
POJO:
@JsonIgnoreProperties(ignoreUnknown=true)
public class TransactionShell
{
private SbAccount transaction;
public TransactionShell() {}
public SbAccount getTransaction() {
return transaction;
}
public void setTransaction(SbAccount transaction) {
this.transaction = transaction;
}
}
Deserialize call:
List<TransactionShell> transactions = Common.mapper.readValue(responseBody, new TypeReference<List<TransactionShell>>() {});
精彩评论