我在尝试将 JSON 解组为对象时遇到 GSON 错误。错误(Expected BEGIN_OBJECT but was STRING at line 3 column 22)指向下面输入的第 3 行。
我没有正确映射 JSON 到 Bean 吗?
import javax.xml.bind.JAXBElement;
public class BusinessPartnerCreate {
protected JAXBElement<String> partnerType;
protected Person person;
protected Company company;
protected String email;
protected String phone;
protected AddressData addressData;
protected AddressClean addressClean;
protected String city;
protected String state;
protected String zipCode;
protected JAXBElement<String> externalId;
}
我的输入 JSON 看起来是这样的:
{
"business-partner-create": {
"partner-type": "1",
"person": {
"firstName": "Dirk",
"lastName": "Wintermill",
"title": ""
},
"email": "kirk@yahoo.com",
"phone": "219-385-2946",
"addressClean": {
"house-number": "10218",
"street-name": "Park",
"street-abbr": "Rd"
},
"city": "Somerset",
"state": "NJ",
"zip-code": "01955"
}
}