I have two java classes for parsing jason into java alone. Beyond that, the classes are not used for any thing. Below are the two classes.
import java.util.ArrayList;
public class PaymentsPaid {
public ArrayList<PaidDetailAmounts> amount;
}
and
public class PaidDetailAmounts {
public Long invoiceFeeId;
public Double amountPaid;
}
Here is where the string and the use of and object mapper.
"amount": [{"invoiceFeeId": 12085, "amountPaid": 100},{"invoiceFeeId": 12084, "amountPaid": 100},{"invoiceFeeId": 12086, "amountPaid": 500}]
and the mapper code
ObjectMapper mapper = new ObjectMapper();
try {
PaymentsPaid paymentsPaidModel = mapper.readValue(httpServletRequest.getParameter("amount"), PaymentsPaid.class);
/*
Iterator<PaidDetailAmounts> iterator = paymentsPaidModel.amount.iterator();
while (iterator.hasNext()) {
System.out.println(iterator.next().invoiceFeeId);
}
*/
} catch (JsonParseException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
This is my exception:
org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field " invoiceFeeId" (Class PACKAGE_NAME.PaymentsPaid), not marked as ignorable
I must be doing something worng, because I built a search feature using this approach and it is currently in my application and working well. Please advise. I think it may be a mal formed json string, because it should be an array.