JSON parse error: Unrecognized field “xxxx“ (classxxxx.xxx.xxx.xx JSON报错

User
JSON parse error: Unrecognized field "imPremodelCode" (class com.immotors.campaign.pojo.dto.res.SlcCommonResDTO$DataSetDTO$MainLeadsDTO), not marked as ignorable; nested exception is com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "imPremodelCode" (class com.immotors.campaign.pojo.dto.res.SlcCommonResDTO$DataSetDTO$MainLeadsDTO), not marked as ignorable (57 known properties: "interestPoint", "smallChannelCode", "angelPoint", "premodelName", "collectTime", "purchaseCityCode", "districtCode", "email", "financePlan", "dealerCode", "smallChannelName", "education", "position", "userLastName", "postCode", "mainLeadId", "csopLevel", "updateTime", "purchaseCityName", "activityName", "vehicleBrand", "vehicleOwnerOption", "provinceCode", "vehicleStatus", "gender", "dealerName", "purchasePlan", "reasonForOwner", "mobileArea", "userFirstName", "imAttractPoint", "communication", "havingBrand", "annualIncome", "createTime", "isIm", "isContinue", "premodelCode", "address", "userName", "cityCode", "fromSystem", "phase", "description", "birthday", "ageRange", "salesCode", "activityCode", "leadStatusValue", "purchaseBudget", "salesName", "isNewEnergy", "leadStatus", "productFault", "intentionLevel", "profession", "company"])
 at [Source: (PushbackInputStream); line: 1, column: 626] (through reference chain: com.immotors.campaign.pojo.dto.res.SlcCommonResDTO["dataSet"]->com.immotors.campaign.pojo.dto.res.SlcCommonResDTO$DataSetDTO["mainLeads"]->java.util.ArrayList[0]->com.immotors.campaign.pojo.dto.res.SlcCommonResDTO$DataSetDTO$MainLeadsDTO["imPremodelCode"])
	at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType

更新JSON:
如果您可以控制JSON数据,确保只包含已知的字段,或者更新JSON结构以匹配MainLeadsDTO类的预期格式。

忽略未知字段:
如果您希望在JSON解析过程中忽略未知字段,可以配置Jackson ObjectMapper来忽略未知属性。您可以在MainLeadsDTO类上添加@JsonIgnoreProperties(ignoreUnknown = true)注解,或者直接配置ObjectMapper。

修改类定义:
如果"imPremodelCode"字段确实是应该包含在MainLeadsDTO类中的有效字段,您需要在类定义中添加相应的属性。确保属性名称与字段名称完全匹配,并考虑添加任何必要的注解或getter/setter方法。

猜你喜欢

转载自blog.csdn.net/a203206868/article/details/131575667