public JSONObject toJSON() { JSONObject jo = new JSONObject(); if (from != null) { jo.put("from", InternetAddress.toString(new InternetAddress[] {from})); } if (subject != null) { jo.put("subject", this.subject); } if (text != null) { jo.put("text", this.text); } if (tos != null) { jo.put("tos", InternetAddress.toString(tos)); } if (ccs != null) { jo.put("ccs", InternetAddress.toString(ccs)); } if (bccs != null) { jo.put("bccs", InternetAddress.toString(bccs)); } // if(files!=null) jo.put("form", $file.toSting(files)); if (error != null) { jo.put("error", error); } if (name != null) { jo.put("name", name); } return jo; }
public static JSONObject load(String base, String id) { File f = new File(base, id + ".json"); try { JSONObject ret = load(f); ret.put("$parent", f.getParent()); return ret; } catch (Exception ex) { ex.printStackTrace(); JOLogger.error("Can't load json [" + f + "]"); } return null; }