mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
fixed issue #3110 , json escapse
This commit is contained in:
@@ -420,12 +420,28 @@ public class JsonConversion {
|
|||||||
for (int i = 0; i < endIndex; ++i) {
|
for (int i = 0; i < endIndex; ++i) {
|
||||||
char c = data.charAt(i);
|
char c = data.charAt(i);
|
||||||
if (c == '"') {
|
if (c == '"') {
|
||||||
sb.append('\\');
|
sb.append("\\\"");
|
||||||
|
} else if (c == '\n') {
|
||||||
|
sb.append("\\n");
|
||||||
|
} else if (c == '\r') {
|
||||||
|
sb.append("\\r");
|
||||||
} else if (c == '\\') {
|
} else if (c == '\\') {
|
||||||
sb.append("\\");
|
sb.append("\\\\");
|
||||||
}
|
} else if (c == '\t') {
|
||||||
|
sb.append("\\t");
|
||||||
|
} else if (c < 16) {
|
||||||
|
sb.append("\\u000");
|
||||||
|
sb.append(Integer.toHexString(c));
|
||||||
|
} else if (c < 32) {
|
||||||
|
sb.append("\\u00");
|
||||||
|
sb.append(Integer.toHexString(c));
|
||||||
|
} else if (c >= 0x7f && c <= 0xA0) {
|
||||||
|
sb.append("\\u00");
|
||||||
|
sb.append(Integer.toHexString(c));
|
||||||
|
} else {
|
||||||
sb.append(c);
|
sb.append(c);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return sb;
|
return sb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user