Com. alibaba. fastjson. JSONException: autoType is not support .,
Solution: https://github.com/alibaba/fastjson/wiki/enable_autotype
Abstract:
I. Add an autotype White List
There are three ways to add a whitelist:
1. Configure in the code
ParserConfig.getGlobalInstance().addAccept("com.taobao.pac.client.sdk.dataobject.");
If there are multiple package name prefixes, multiple times addAccept
2. Add JVM startup parameters
-Dfastjson.parser.autoTypeAccept=com.taobao.pac.client.sdk.dataobject.,com.cainiao.
If multiple package name prefixes exist, separate them with commas (,).
3. Configure through the fastjson. properties file.
In version 1.2.25/1.2.26, The fastjson. properties file of the class path is supported. The configuration method is as follows:
Fastjson. parser. autoTypeAccept = com. taobao. pac. client. sdk. dataobject., com. cainiao. // If there are multiple package name prefixes, separate them with commas (,).
Ii. Enable the autotype Function
If the problem cannot be solved by configuring the whitelist, you can enable the autotype function. fastjson has multiple built-in protections in the new version, but there may still be risks. Use either of the following methods to open autotype:
1. JVM startup parameters
-Dfastjson.parser.autoTypeSupport=true
2. Set in the code
ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
If non-Global ParserConfig is used, use setAutoTypeSupport (true );