@Test public void testEscapingNullString() { String revisedText = escapeJson.escapeJson(null); Assert.assertNull(revisedText); }
public String escapeJson(final String text) { String revisedText = null; if (text != null) { StringBuilder sb = new StringBuilder(text.length() * 2); for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); switch (c) { case '\"': sb.append("\\\""); break; default: sb.append(c); } } revisedText = sb.toString(); } return revisedText; }
EscapeJson { public String escapeJson(final String text) { String revisedText = null; if (text != null) { StringBuilder sb = new StringBuilder(text.length() * 2); for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); switch (c) { case '\"': sb.append("\\\""); break; default: sb.append(c); } } revisedText = sb.toString(); } return revisedText; } }
EscapeJson { public String escapeJson(final String text) { String revisedText = null; if (text != null) { StringBuilder sb = new StringBuilder(text.length() * 2); for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); switch (c) { case '\"': sb.append("\\\""); break; default: sb.append(c); } } revisedText = sb.toString(); } return revisedText; }  }
EscapeJson { public String escapeJson(final String text) { String revisedText = null; if (text != null) { StringBuilder sb = new StringBuilder(text.length() * 2); for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); switch (c) { case '\"': sb.append("\\\""); break; default: sb.append(c); } } revisedText = sb.toString(); } return revisedText; }  String escapeJson(final String text); }
EscapeJson { public String escapeJson(final String text) { String revisedText = null; if (text != null) { StringBuilder sb = new StringBuilder(text.length() * 2); for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); switch (c) { case '\"': sb.append("\\\""); break; default: sb.append(c); } } revisedText = sb.toString(); } return revisedText; }  String escapeJson(final String text);  }