String dataId = "0000000000003000-0001"; String baisc= " { " + " \"SIZE\":\"0\"," + " \"UPDATE\":\"2014-12-01 23:01:23.98765\"," + " \"ERR\":\"ssss\"" + " }"; // JSONObject obj = JSONObject.fromObject(baisc); // System.out.println(obj.toString()); JSONObject returnStr=new JSONObject(); returnStr.put("DATAID", dataId); JSONObject bas = new JSONObject(); bas.put("SIZE", "1"); bas.put("UPDATE", new SimpleDataFormat("yyyy-MM-dd HH:mm:ss.SSS"));//当前时间 bas.put("ERR", ""); //如果直接放入baisc参数,得到的是错误的json字符串 returnStr.put("BAISC", bas); System.out.println(returnStr.toString());
时间: 2024-09-28 22:54:40