@Test public void stripComment() throws Exception { String source = " "{\n" + " " k11: \"v11\",\n" + " k12: \"v12\", \t " " k13: \"v13\", \t "\n" + " \n" + " k21: \"v21\",\n" + " k22: \"v22\", \t\n" + " \t\n" + " k23: \"v23\", \t \t\n" + "\n" + " \n" + " k31: \"v31\",\n" + " \n" + " k32: \"v32\",\n" + " \n" + " k33: \"v33\",\n" + " ke:0\n" + "}"; System.out.println("source=" + source); String result = JsonUtils.stripComment(source); System.out.println("result=" + result); JSONObject json = new JSONObject(result); System.out.println("json=" + json); }
public static String stripComment(String source) { return source == null ? null : source.replaceAll("\\s* }
JsonUtils { public static String stripComment(String source) { return source == null ? null : source.replaceAll("\\s* } }
JsonUtils { public static String stripComment(String source) { return source == null ? null : source.replaceAll("\\s* } private  JsonUtils(); }
JsonUtils { public static String stripComment(String source) { return source == null ? null : source.replaceAll("\\s* } private  JsonUtils(); static String stripComment(String source); static String toJson(Object source); static Map<String, Object> toMap(String json); static Object[] toArray(String json); static Collection<T> toCollection(String json); }
JsonUtils { public static String stripComment(String source) { return source == null ? null : source.replaceAll("\\s* } private  JsonUtils(); static String stripComment(String source); static String toJson(Object source); static Map<String, Object> toMap(String json); static Object[] toArray(String json); static Collection<T> toCollection(String json);  }