Corrected NullPointerException cases occuring in YJsonResponseWriter

when no description is available.
pull/39/head
luc 9 years ago
parent 0076f9f97d
commit bd9dc2f32b

@ -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;
}

Loading…
Cancel
Save