gpt4 book ai didi

Unrecognized properties error not marked as ignorable(无法识别的属性错误未标记为可忽略)

转载 作者:bug小助手 更新时间:2023-10-24 17:55:06 34 4
gpt4 key购买 nike




ERROR:
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "status" not marked as ignorable (11 known properties: "method", "sequenceNo", "statusMessage", "timestamp", "supportMessage", "customerId", "data", "statusCode", "path", "transactionId", "_links"])



CODE:

代码:


@Data @JsonInclude(JsonInclude.Include.NON_NULL) 
public class KYCScoreIndResponse {
private String customerId;
private String statusCode;
private String statusMessage;
private String supportMessage;
private String transactionId;
private KYCData data;
private String sequenceNo;
private String path;
private String method;
private String timestamp;
@JsonIgnore private HttpStatus httpStatus;
private Links _links;
}

How to solve the error i tried using @jsonproperty of each parameter but not working

如何解决我尝试使用每个参数的@jsonProperty但不起作用的错误


更多回答

I think you have used the wrong property name somewhere: "status" != "httpStatus".

我认为您在某个地方使用了错误的属性名称:“Status”!=“HttpStatus”。

duplicate of stackoverflow.com/questions/4486787/…

Stackoverflow.com/Questions/4486787/…的副本

@TheincredibleJan Technically true, but it won't help. The problem here is using the right property name, not ignoring the property which is the only thing suggested in that question's top answers.

@TheUnderbleJan技术上是正确的,但它不会有帮助。这里的问题是使用正确的属性名称,而不是忽略该问题的最高答案中唯一建议的属性。

Can you explain your issue first?

你能先解释一下你的问题吗?

优秀答案推荐

If you want to apply @JsonIgnoreProperties to all class in you application then the best way it is override Spring boot default jackson object.

如果您想将@JsonIgnoreProperties应用于应用程序中所有类,那么最好的方法是覆盖Spring Boot的默认Jackson对象。


In you application config file define a bean to create jackson object mapper like this.

在您应用程序配置文件中定义一个Bean来创建如下所示的Jackson对象映射器。


@Bean
public ObjectMapper getObjectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return mapper;
}

Now, you don't need to mark every class and it will ignore all unknown properties.

现在,您不需要标记每个类,它将忽略所有未知属性。


更多回答

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com