Com. alibaba. fastjson. JSONException: autoType is not support .,

Source: Internet
Author: User

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 );

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.