List of utility methods to do Json String Create
String | toJson() Problem of Json is that we need to distinguish throw new UnsupportedOperationException("Not supported yet."); |
String | toJson(final Document doc) to Json return toJson(doc, false);
|
String | toJson(Object value) to Json return value.toString();
|
String | toJson(String jsonp) to Json final String prefix = "loaded("; final String suffix = ")"; return jsonp.substring(0 + prefix.length(), jsonp.length() - suffix.length()); |
String | toJson(String org) to Json StringBuffer result = new StringBuffer(org.length()); char[] chars = org.toCharArray(); for (int i = 0; i < chars.length; i++) { if (chars[i] == '\"') result.append("""); else if (chars[i] == '\'') result.append("'"); else if (chars[i] == '\\') ... |
String | toJson(String s) Converts a String to a JSON String. if (s != null) { StringBuilder sb = new StringBuilder(); sb.append('"'); int len = s.length(); for (int i = 0; i < len; i++) { char c = s.charAt(i); switch (c) { case '\\': ... |
String | toJson(String str) to Json if (str == null) { return str; StringBuilder sb = new StringBuilder(); int len = str.length(); for (int i = 0; i < len; i++) { char c = str.charAt(i); switch (c) { ... |
String | toJson(String str) to Json int len = str.length(); StringBuilder buf = new StringBuilder(); buf.append('\"'); for (int i = 0; i < len; i++) { char ch = str.charAt(i); if (ch == '\n') buf.append("\\n"); else if (ch == '\r') ... |
String | toJSON(String string) to JSON if (string != null) { string = string.replace("\"", "\\\""); return string; |
String[] | toJsonArrays(String... strings) to Json Arrays String[] jsonArrays = new String[strings.length]; for (int i = 0; i < strings.length; i++) { jsonArrays[i] = "[\"" + strings[i] + "\"]"; return jsonArrays; |