Permalink
Browse files

Don't generate invalid JSON for unprintable chars

  • Loading branch information...
1 parent 31d32f4 commit 4272a3332028583b2fa18b7cef2885f4341b2f9e @ept committed Sep 6, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java
@@ -445,9 +445,9 @@ private void writeEscapedString(String string, StringBuilder builder) {
if((ch>='\u0000' && ch<='\u001F') || (ch>='\u007F' && ch<='\u009F') || (ch>='\u2000' && ch<='\u20FF')){
String hex = Integer.toHexString(ch);
builder.append("\\u");
- for(int j = 0; j < 4-builder.length(); j++)
+ for(int j = 0; j < 4-hex.length(); j++)
builder.append('0');
- builder.append(string.toUpperCase());
+ builder.append(hex.toUpperCase());
} else {
builder.append(ch);
}

0 comments on commit 4272a33

Please sign in to comment.