When JavaBean turn JSON string, the field name is missing the first letter of the question


Problem Description:

javabean contains the boolean field suspend, idea and method of automatically generating a getSuspend isSuspend method.
When previously used orj.json json string for conversion is not a problem { "suspend": "true" }. After conversion method back to colleagues json fastjson obtained result string { "uspend": "true" }, less initials s.

problem causes

JavaBean specification of a predetermined boolean getter / setter is isXXX / setXXX, the packaging Boolean getter / setter is getXXX / setXXX, where XXX is a variable name (IDE generated code is the default format).
fastjson when parsing is to obtain key according javaBean get and set methods.

Solution:

The method of manually modify getSuspend isSuspend method.
Note: isSuspend and getSuspend not exist, otherwise it will be JSON string conversion fails.

Published 16 original articles · won praise 1 · views 10000 +

Guess you like

Origin blog.csdn.net/a0604030212/article/details/102815522