架构师之--------通讯传输json原生态通用转换和逆转换
1.前言.
至少要用到jar包json-lib-2.4-jdk15.jar.
2.例子.
import java.io.UnsupportedEncodingException;
import net.sf.json.JSONObject;
public class test {
public static void main(String[] args) throws UnsupportedEncodingException {
JSONObject jsonObject=new JSONObject();
JSONObject jsonObject1=new JSONObject();
jsonObject1.accumulate("kk1", "few");
jsonObject1.accumulate("kk2", "few");
jsonObject.accumulate("kkk", "kkk");
jsonObject.accumulate("json", jsonObject1);
//System.out.println("住"jsonObject.toString());
String jString=jsonObject.toString();
System.out.println("转换前:"+jsonObject.toString());
System.out.println("转换后的子objec"+(JSONObject)JSONObject.fromObject(jString).getJSONObject("json"));
}
} 相关推荐
ruancw 2020-08-27
frank0 2020-08-26
wl00 2020-08-26
TuxedoLinux 2020-08-18
程序员生态圈 2020-08-04
lovecodeblog 2020-07-28
Cricket 2020-06-14
Noseparte 2020-06-13
架构技术交流 2020-06-11
舍我其谁 2020-06-09
yuanxiaogang 2020-06-06
范群松 2020-06-06
quguang 2020-06-06
85231843 2020-05-31
ChenRuiyz 2020-05-15
Jaiky杰哥 2020-05-15
DAV数据库 2020-05-07