1、在pom.xml中引入fastjson依赖
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.62</version>
</dependency>
2、准备封装数据实体类
@Data
@TableName("plan_channel_rels")
public class PlanChannelRel {
@TableId(value = "id", type = IdType.INPUT)
private String id;
@TableField("plan_id")
private String planId;
@TableField("channel_id")
private String channelId;
}
@Data
public class PlanChannelRelDTO extends PlanChannelRel {
@TableField("channel_type_id")
private String channelTypeId;
@TableField("description")
private String description;
}
3、反序化
String jsonStr = "[{"channelId":"28f9cad5-7e12-449d-b857-fc2d4d4bd9d9","description":"张三、王五","channelTypeId":"2d92e906-e550-46c5-b95d-f8e855a45bf3"},{"channelId":"564a8339-ff19-4c6b-bb57-648b97d9a19e","description":"192.168.0.1","channelTypeId":"b19ca4ed-21e1-4d70-87d3-9f2d6125a671"}]";
List<PlanChannelRelDTO> relList = JSONArray.parseArray(jsonStr, PlanChannelRelDTO.class);
路漫漫其修远兮,吾将上下而求索
译文:在追寻真理方面,前方的道路还很漫长,但我将百折不挠,不遗余力地去追求和探索。
如果您有什么好的想法与方法,欢迎在评论区留言,我们一起讨论~
本文暂时没有评论,来添加一个吧(●'◡'●)