数据[源头,目标,信息]
源头:c1
目标:c2
信息:123
1、封装(发送)
//封装
JSONObject jsonObject=new JSONObject();
jsonObject.put("from", "c1");
jsonObject.put("to", "c2");
jsonObject.put("msg", "123");
String str=jsonObject.toString();
System.out.println(str);
2、解析(接收)
//解析
JSONObject jsonObject2=JSONObject.fromObject(str);
String msg=jsonObject2.getString("msg");
System.out.println(msg);