The list of methods to do Json Escape are organized into topic(s).
String
escape4Json(String source) escape Json
if (source == null) {
return "";
StringBuilder buf = new StringBuilder();
CharacterIterator it = new StringCharacterIterator(source);
for (char c = it.first(); c != CharacterIterator.DONE; c = it.next()) {
if (c == '"') {
buf.append("\\\"");
...
String
escapeJSON(String aText) escape JSON
if (aText == null) {
return null;
final StringBuilder result = new StringBuilder();
StringCharacterIterator iterator = new StringCharacterIterator(aText);
char character = iterator.current();
while (character != StringCharacterIterator.DONE) {
if (character == '\"') {
...
String
jsonEscape(CharSequence s) Escapes json characters in the passed string
return s.toString().replace("\"", "\\\"").replace("[", "\\[").replace("]", "\\]").replace("{", "\\{")
.replace("}", "\\}");
String
jsonEscape(String in) Escape value to be used in JSON.
if (in == null || in.isEmpty())
return in;
return in.replace("\\", "\\\\").replace("\n", "\\n").replace("\"", "\\\"").replace("\r", "\\r")
.replace("\t", "\\t").replace("\b", "\\b").replace("\f", "\\f");
String
jsonEscape(String s) json Escape
StringBuilder sb = new StringBuilder();
int len = s.length();
for (int i = 0; i < len; i++) {
char ch = s.charAt(i);
switch (ch) {
case '"':
sb.append("\\\"");
break;
...
String
jsonEscape(String str) json Escape
StringBuilder sb = new StringBuilder();
sb.append("\"");
for (int i = 0; i < str.length(); i++) {
char ch = str.charAt(i);
int found = -1;
for (int k = 0; k < ESC_MAP.length && found == -1; k++) {
if (ch == ESC_MAP[k])
found = k;
...
String
jsonEscape(String string) json Escape
if (string == null || string.length() == 0) {
return "\"\"";
char c = 0;
int i;
int len = string.length();
StringBuilder sb = new StringBuilder(len + 4);
String t;
...
String
jsonEscapes(String str) json Escapes
StringBuilder escaped = new StringBuilder();
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i)) {
case 0:
continue;
case '\b':
escaped.append("\\\\b");
continue;
...