Java对象与JSON互转
作者:
AC编程 | 来源:发表于
2022-12-02 11:32 被阅读0次一、对象与JSON互转
OrderCmd orderCmd = new OrderCmd();
//对象转JSOn
String orderJson = JSON.toJSONString(orderCmd);
//JSON转对象
OrderCmd orderCmd = JSONObject.parseObject(orderJson, OrderCmd.class);
二、集合与JSON互转
//集合转JSON
String attachmentsJSON = JSON.toJSONString(vo.getAttachmentList());
//JSON转集合
List<MessageAttachment> attachmentList = JSONObject.parseArray(attachmentsJSON, MessageAttachment.class);
本文标题:Java对象与JSON互转
本文链接:https://www.haomeiwen.com/subject/uzuefdtx.html
网友评论