When fastjson uses JSON.toJSONString, the byte[] data will be automatically converted to base64

question

As the title states, when using fastjson to process list<list<byte[]>> data and convert it to json, there is a situation where it is automatically converted to base64.

Call the JSON.toJSONString command. Different fastjson versions will automatically convert the byte array into base64.

If you deserialize json again, you need to perform base64 decryption.

After testing, versions with different performances appeared.

Automatically convert to base64 version

    <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>2.0.20</version>
        </dependency>

A version that does not automatically convert to base64

    <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>2.0.18</version>
        </dependency>

<dependency>
    <groupId>com.alibaba.fastjson2</groupId>
    <artifactId>fastjson2</artifactId>
    <version>2.0.20</version>
</dependency>

Guess you like

Origin blog.csdn.net/Mint6/article/details/130037541