added serverObjects.putJSON as JSON has very particulare encoding requirements

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5877 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
apfelmaennchen 16 years ago
parent 557c2a32a3
commit 138a0747e3

@ -146,6 +146,27 @@ public class serverObjects extends HashMap<String, String> implements Cloneable
public String put(final String key, final InetAddress value) { public String put(final String key, final InetAddress value) {
return this.put(key, value.toString()); return this.put(key, value.toString());
} }
/**
* Add a String to the map. The content of the String is escaped to be usable in JSON output.
* @param key key name as String.
* @param value a String that will be reencoded for JSON output.
* @return the modified String that was added to the map.
* @see htmlFilterCharacterCoding#encodeUnicode2json(String, boolean)
*/
public String putJSON(final String key, String value) {
value = value.replaceAll("\"", "\\\"");
value = value.replaceAll("/", "\\/");
// value = value.replaceAll("\\", "\\\\");
value = value.replaceAll("\b", "\\b");
value = value.replaceAll("\f", "\\f");
value = value.replaceAll("\n", "\\r");
value = value.replaceAll("\r", "\\r");
value = value.replaceAll("\t", "\\t");
return put(key, value);
}
public String putJSON(final String key, final byte[] value) {
return putJSON(key, new String(value));
}
/** /**
* Add a String to the map. The content of the String is escaped to be usable in HTML output. * Add a String to the map. The content of the String is escaped to be usable in HTML output.

Loading…
Cancel
Save