Olá, estou tentando converter um JSON para Object utilizando a API do Jackson, porém estou enfrentando problemas referente a um atributo List<> que possuo no objeto a ser criado. Segue o JSON que estou tentando converter:
JSON:
[{
“orderId”: “845770843550-01”,
“creationDate”: “2018-07-10T17:13:59.0000000+00:00”,
“clientName”: “Bruno de Andrade Simões de Almeida”,
“items”: [{
“seller”: “1”,
“quantity”: 1,
“description”: “ADESIVO VTEX 2 - TITULO SITE”,
“ean”: “7000000250385”,
“refId”: “7000000250385”,
“id”: “3”,
“productId”: “4”,
“sellingPrice”: 5455,
“price”: 5455
}],
“totalValue”: 5456.0,
“paymentNames”: “Visa”,
“status”: “ready-for-handling”,
“statusDescription”: “Pronto para o manuseio”,
“marketPlaceOrderId”: null,
“sequence”: “500007”,
“salesChannel”: “1”,
“affiliateId”: “”,
“origin”: “Marketplace”,
“workflowInErrorState”: false,
“workflowInRetry”: false,
“lastMessageUnread”: " Alan Rivail Silva Filho 96 Seu pagamento foi aprovado. Referente ao Pedido #845770843550-01 Olá, Bruno. Estamos providenciando a emissão da",
“ShippingEstimatedDate”: “2018-07-12T17:14:31.0000000+00:00”,
“orderIsComplete”: true,
“listId”: null,
“listType”: null,
“authorizedDate”: “2018-07-10T17:14:30.0000000+00:00”,
“callCenterOperatorName”: null
}]
Objeto a ser criado a partir deste JSON:
public class Order {
private String orderId;
private String creationDate;
private String clientName;
private List<Item> items;
private Double totalValue;
private String paymentNames;
private String status;
private String statusDescription;
private String marketPlaceOrderId;
private String sequence;
private String salesChannel;
private String affiliateId;
private String origin;
private Boolean workflowInErrorState;
private Boolean workflowInRetry;
private String lastMessageUnread;
private String ShippingEstimatedDate;
private Boolean orderIsComplete;
private String listId;
private String listType;
private String authorizedDate;
private String callCenterOperatorName;
public class Item {
private Double quantity;
private String description;
private String ean;
private String refId;
private String id;
private String productId;
private Double sellingPrice;
private Double price;
//Getters e Setters
}
//Getters e Setters
}
Método para conversão:
public static List getObjectListFromJson(String pJson, Class pClass) throws EciVtexException {
List vObjectList = null;
try {
ObjectMapper vMapper = new ObjectMapper();
vObjectList = vMapper.readValue(pJson, vMapper.getTypeFactory().constructCollectionType(ArrayList.class, pClass));
}catch (Exception e) {
throw new EciVtexException("===> Erro na transformação do JSON em lista de objeto: " + e.getMessage(), e);
}
return vObjectList;
}
Exception:
Unrecognized field “items” (class br.com.infoxnet.ecivtex.model.Order), not marked as ignorable (22 known properties: “lastMessageUnread”, “sequence”, “paymentNames”, “workflowInRetry”, “origin”, “affiliateId”, “orderId”, “statusDescription”, “creationDate”, “orderIsComplete”, “status”, “clientName”, “salesChannel”, “listType”, “listId”, “shippingEstimatedDate”, “marketPlaceOrderId”, “itens”, “callCenterOperatorName”, “authorizedDate”, “totalValue”, “workflowInErrorState”])
at [Source: (String)"[{“orderId”:“845770843550-01”,“creationDate”:“2018-07-10T17:13:59.0000000+00:00”,“clientName”:“Bruno de Andrade Simões de Almeida”,“items”:[{“seller”:“1”,“quantity”:1,“description”:“ADESIVO VTEX 2 - TITULO SITE”,“ean”:“7000000250385”,“refId”:“7000000250385”,“id”:“3”,“productId”:“4”,“sellingPrice”:5455,“price”:5455}],“totalValue”:5456.0,“paymentNames”:“Visa”,“status”:“ready-for-handling”,“statusDescription”:“Pronto para o manuseio”,“marketPlaceOrderId”:null,“sequence”:“500007”,“salesChannel”:“1"”[truncated 456 chars]; line: 1, column: 142] (through reference chain: java.util.ArrayList[0]->br.com.infoxnet.ecivtex.model.Order[“items”])
Alguém teria alguma ideia do que está errado?
Agradeço desde já a atenção. Obrigado.