Simple implementation of Java Map conversion entity class object

In the development process, there are often too many tables to directly transfer values ​​according to Map. In some scenarios, Map needs to be converted to entity classes. Here is the most concise method that depends on Ali's FastJSon.
maven introduction

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

Class introduction

import com.alibaba.fastjson.JSON;

Conversion method

Student entity = JSON.parseObject(JSON.toJSONString(map), Student.class);

End of work

Guess you like

Origin blog.csdn.net/qq_23140197/article/details/86503875