我的杰森:
this.restify.use((req, res, next) => {
res.header("API-TOKEN", 'GHYTYEUJSJSHHEYHJSH');
return next();
})
[
{
"accountId": "1005003805",
"status": "1000",
"internalStatus": "ACTIVE",
"associations": [
{
"id": "1000004114",
"type": "reseller"
}
],
"preferredLanguage": "it-IT",
"address": {
"country": "IT",
"phoneNumber": "408-536-3538",
"city": "SESTO FIORENTINO",
"postalCode": "50019",
"addressLine1": "345 Park Ave",
"addressLine2": "VIA DONINZETTI 17",
"region": "32"
},
"name": "UPLOAD DI RICCI LUCA E PROCELLI SNC anil",
"type": "customer",
"externalReferenceId": "Su66353456234",
"contacts": [
{
"firstName": "su",
"lastName": "ku",
"phoneNumber": "408-536-3538",
"type": "ADMIN",
"email": "dis+testingapi@adobetest.com",
"adminId": "6436457474D"
}
],
"createdDate": "2019-11-08T13:54:30.000+0000",
"statusReason": "Account is activated",
"accountCode": "21",
"tenantId": "5tetewt3532",
"cotermDate": ""
},
{
"accountId": "1000004114",
"status": "1000",
"internalStatus": "ACTIVE",
"associations": [
{
"id": "1655325",
"type": "distributor"
}
],
"preferredLanguage": "it-IT",
"address": {
"country": "IT",
"phoneNumber": "",
"city": "San Giuliano",
"postalCode": "20098",
"addressLine1": "Via L. Tolstoi 65",
"addressLine2": "",
"region": "47"
},
"name": "Ad6745e53262362",
"type": "reseller",
"externalReferenceId": "re634le75358932",
"contacts": [
{
"firstName": "Abc",
"lastName": "An",
"phoneNumber": "408-536-3538",
"type": "ADMIN",
"email": "a@adobe.com",
"adminId": ""
}
],
"createdDate": "2019-11-08T06:35:58.000+0000",
"statusReason": "Account is activated",
"accountCode": "11",
"tenantId": "",
"cotermDate": ""
},
{
"accountId": "16364649",
"status": "1000",
"internalStatus": "ACTIVE",
"associations": [],
"preferredLanguage": "en-US",
"address": {
"country": "IT",
"phoneNumber": "",
"city": "San Giuliano",
"postalCode": "20098",
"addressLine1": "Via L. Tolstoi 65",
"addressLine2": "",
"region": "47"
},
"name": "Stage Tech Data Italy",
"type": "distributor",
"externalReferenceId": "invalid",
"contacts": [
{
"firstName": "arr",
"lastName": "dummy",
"phoneNumber": "",
"type": "ADMIN",
"email": "aty+vmp8@adobetest.com",
"adminId": ""
}
],
"statusReason": "Manually created for testing",
"accountCode": "01",
"tenantId": "6456",
"cotermDate": ""
}
]
package adobe_Partner_Api_ECCS_PojoClasses;
import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonFormat;
@JsonFormat(shape = JsonFormat.Shape.ARRAY)
public class ECCSGetExtraCustomer {
private String accountId;
private String status;
private String internalStatus;
private String statusReason;
private String externalReferenceId;
private String tenantId;
private String type;
private String name;
private String marketSegment;
private String preferredLanguage;
private String cotermDate;
private String creationDate;
private Address address;
private ArrayList<Contacts> contacts;
private ArrayList<Associations> associations;
public ArrayList<Contacts> getContacts() {
return contacts;
}
public void setContacts(ArrayList<Contacts> contacts) {
this.contacts = contacts;
}
public ArrayList<Associations> getAssociations() {
return associations;
}
public void setAssociations(ArrayList<Associations> associations) {
this.associations = associations;
}
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getInternalStatus() {
return internalStatus;
}
public void setInternalStatus(String internalStatus) {
this.internalStatus = internalStatus;
}
public String getStatusReason() {
return statusReason;
}
public void setStatusReason(String statusReason) {
this.statusReason = statusReason;
}
public String getExternalReferenceId() {
return externalReferenceId;
}
public void setExternalReferenceId(String externalReferenceId) {
this.externalReferenceId = externalReferenceId;
}
public String getTenantId() {
return tenantId;
}
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMarketSegment() {
return marketSegment;
}
public void setMarketSegment(String marketSegment) {
this.marketSegment = marketSegment;
}
public String getPreferredLanguage() {
return preferredLanguage;
}
public void setPreferredLanguage(String preferredLanguage) {
this.preferredLanguage = preferredLanguage;
}
public String getCotermDate() {
return cotermDate;
}
public void setCotermDate(String cotermDate) {
this.cotermDate = cotermDate;
}
public String getCreationDate() {
return creationDate;
}
public void setCreationDate(String creationDate) {
this.creationDate = creationDate;
}
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
public static class Address {
private String country;
private String region;
private String city;
private String addressLine1;
private String addressLine2;
private String postalCode;
private String phoneNumber;
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getAddressLine1() {
return addressLine1;
}
public void setAddressLine1(String addressLine1) {
this.addressLine1 = addressLine1;
}
public String getAddressLine2() {
return addressLine2;
}
public void setAddressLine2(String addressLine2) {
this.addressLine2 = addressLine2;
}
public String getPostalCode() {
return postalCode;
}
public void setPostalCode(String postalCode) {
this.postalCode = postalCode;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
}
public static class Contacts {
private String type;
private String firstName;
private String lastName;
private String email;
private String phoneNumber;
private String adminId;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getAdminId() {
return adminId;
}
public void setAdminId(String adminId) {
this.adminId = adminId;
}
}
public static class Associations {
private String type;
private String id;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
}
答案 0 :(得分:0)
您收到此错误是因为您在类的顶部放置了 @JsonFormat(shape = JsonFormat.Shape.ARRAY)批注,对于您而言,我认为这是不必要的。
您的POJO类中也存在一些错误,它缺少accountCode字段,并且createdDate字段被命名为creationDate。
public class ECCSGetExtraCustomer {
private String accountId;
private String accountCode;
private String createdDate;
//... + Getters and setters
}
要反序列化您的json为列表,您可以这样:
public class LaunchDebug {
public void main() throws Exception {
ObjectMapper objectMapper = new ObjectMapper();
List<ECCSGetExtraCustomer> eccsGetExtraCustomer = Arrays.asList(objectMapper.readValue(value, ECCSGetExtraCustomer[].class));
System.out.println(eccsGetExtraCustomer.toString());
}
}