dev.robocode.tankroyale.botapi.util.JsonUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of robocode-tankroyale-bot-api Show documentation
Show all versions of robocode-tankroyale-bot-api Show documentation
Robocode Tank Royale Bot API for Java
The newest version!
package dev.robocode.tankroyale.botapi.util;
/**
* Utility class for JSON.
*/
public class JsonUtil {
// Hide constructor to prevent instantiation
private JsonUtil() {
}
public static String escaped(String s) {
return s.replaceAll("\b", "\\\\b") // backspace -> \b
.replaceAll("\f", "\\\\f") // form feed -> \f
.replaceAll("\n", "\\\\n") // newline -> \n
.replaceAll("\r", "") // carriage return -> remove character
.replaceAll("\t", "\\\\t") // tab -> \t
.replaceAll("\"", "\\\\\"") // double-quotes -> \"
.replaceAll("\\\\", "\\\\") // single backslash (\) -> double backslash (\\)
;
}
}