I\'m using Spring\'s RestTemplate to consume the Chargify API, using JSON as the payload format. It has been going pretty smoothly, however when I try to GET an array of obj
You just need another wrapper type on top of Transaction, also please remove the UNWRAP_ROOT_VALUE option.
The classes will be along these lines:
public class TransactionHolder {
private Transaction transaction;
...
}
public class Transaction {
private String amount_in_cents;
private String created_at;
private int ending_balance_in_cents;
private int id;
private String kind;
private String memo;
private int payment_id;
private int product_id;
private int subscription_id;
private boolean success;
private String transaction_type;
private String type;
...
}
With your sample json, the following works for me cleanly:
ObjectMapper mapper = new ObjectMapper();
InputStream is = this.getClass().getResourceAsStream("sample.json");
TransactionHolder[] holders = mapper.readValue(is,TransactionHolder[].class);