Could not write JSON document: (was java.lang.NullPointerException) (through reference chain

I just tested and raised a bug query error, so I found it, the reason is the json problem, look at the reported error, and look at the bean, there is no problem. I looked for it later; I was surprised to see what a big brother said. . . It was a hole.

In the project, we will build entity beans under the model package. The data type of the attributes of each entity may use the basic type; it may also use the wrapper type. Sometimes, when processing the business, we directly modify the field type of the bean to use the setter/getter method. Regenerate, for example, one of my field types only changes the basic type of the property (such as double) to a wrapper type (such as Double), but does not modify the type of the setter/getter together.

  This situation will report an error, and the error reported is often confusing. The following is a case where the above-mentioned negligent error occurs when com.fasterxml.jackson is used to serialize Entity into a Json string:

com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference 

my bean:

private Double receiveDis;

public double getReceiveDis() {
return receiveDis;
}

public void setReceiveDis(double receiveDis) {
this.receiveDis = receiveDis;
}

 

Modify double to the original encapsulated type Double 

This hole is really deep. Take a note; I hope you all take note.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324932094&siteId=291194637