|
|
|
@ -288,8 +288,13 @@ public class serverObjects implements Serializable, Cloneable {
|
|
|
|
|
put(key, toJSON(value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Convert string value to be usable in JSON ouput
|
|
|
|
|
* @param value value to encode
|
|
|
|
|
* @return encoded value, empty string when value is null
|
|
|
|
|
*/
|
|
|
|
|
public static String toJSON(String value) {
|
|
|
|
|
// value = value.replaceAll("\\", "\\\\");
|
|
|
|
|
if (value != null) {
|
|
|
|
|
value = patternDoublequote.matcher(value).replaceAll("'");
|
|
|
|
|
value = patternSlash.matcher(value).replaceAll("\\/");
|
|
|
|
|
value = patternB.matcher(value).replaceAll("\\b");
|
|
|
|
@ -297,6 +302,9 @@ public class serverObjects implements Serializable, Cloneable {
|
|
|
|
|
value = patternNewline.matcher(value).replaceAll("\\r");
|
|
|
|
|
value = patternR.matcher(value).replaceAll("\\r");
|
|
|
|
|
value = patternT.matcher(value).replaceAll("\\t");
|
|
|
|
|
} else {
|
|
|
|
|
value = "";
|
|
|
|
|
}
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|