@Test void serializeOrgJsonArrayWorks() { org.json.JSONArray array = new org.json.JSONArray(); array.put("a"); array.put(42); array.put(true); assertEquals("[\"a\",42,true]", this.tool.serialize(array)); }
public String serialize(Object object) { try { ObjectMapper mapper = new ObjectMapper(); SimpleModule m = new SimpleModule("org.json.* serializer", new Version(1, 0, 0, "", "org.json", "json")); m.addSerializer(JSONObject.class, new JSONObjectSerializer()); m.addSerializer(JSONArray.class, new JSONArraySerializer()); mapper.registerModule(m); return mapper.writeValueAsString(object); } catch (JsonProcessingException e) { LOGGER.error("Failed to serialize object to JSON", e); } return null; }
JSONTool { public String serialize(Object object) { try { ObjectMapper mapper = new ObjectMapper(); SimpleModule m = new SimpleModule("org.json.* serializer", new Version(1, 0, 0, "", "org.json", "json")); m.addSerializer(JSONObject.class, new JSONObjectSerializer()); m.addSerializer(JSONArray.class, new JSONArraySerializer()); mapper.registerModule(m); return mapper.writeValueAsString(object); } catch (JsonProcessingException e) { LOGGER.error("Failed to serialize object to JSON", e); } return null; } }
JSONTool { public String serialize(Object object) { try { ObjectMapper mapper = new ObjectMapper(); SimpleModule m = new SimpleModule("org.json.* serializer", new Version(1, 0, 0, "", "org.json", "json")); m.addSerializer(JSONObject.class, new JSONObjectSerializer()); m.addSerializer(JSONArray.class, new JSONArraySerializer()); mapper.registerModule(m); return mapper.writeValueAsString(object); } catch (JsonProcessingException e) { LOGGER.error("Failed to serialize object to JSON", e); } return null; }  }
JSONTool { public String serialize(Object object) { try { ObjectMapper mapper = new ObjectMapper(); SimpleModule m = new SimpleModule("org.json.* serializer", new Version(1, 0, 0, "", "org.json", "json")); m.addSerializer(JSONObject.class, new JSONObjectSerializer()); m.addSerializer(JSONArray.class, new JSONArraySerializer()); mapper.registerModule(m); return mapper.writeValueAsString(object); } catch (JsonProcessingException e) { LOGGER.error("Failed to serialize object to JSON", e); } return null; }  String serialize(Object object); Object fromString(String str); @Deprecated JSON parse(String json); }
JSONTool { public String serialize(Object object) { try { ObjectMapper mapper = new ObjectMapper(); SimpleModule m = new SimpleModule("org.json.* serializer", new Version(1, 0, 0, "", "org.json", "json")); m.addSerializer(JSONObject.class, new JSONObjectSerializer()); m.addSerializer(JSONArray.class, new JSONArraySerializer()); mapper.registerModule(m); return mapper.writeValueAsString(object); } catch (JsonProcessingException e) { LOGGER.error("Failed to serialize object to JSON", e); } return null; }  String serialize(Object object); Object fromString(String str); @Deprecated JSON parse(String json);  }