第一步 添加谷歌 依赖 <!--实体类转JSON--> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.8.6</version> </dependency>
第二步 把实体类转String String gsonStr = new Gson().toJson(styleVo);
第三部
JSONObject jsonObject = JSONObject.parseObject(gsonStr);
ok了。
详细看原文章