Skip to content

Commit c802418

Browse files
committed
json fix
1 parent be4ad50 commit c802418

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/main/com/mongodb/util/JSON.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ else if(c == '\r')
3737
a.append("\\r");
3838
else if(c == '\t')
3939
a.append("\\t");
40+
else if(c == '\b')
41+
a.append("\\b");
4042
else if ( c < 32 )
4143
continue;
4244
else
@@ -376,6 +378,7 @@ else if(check('\"'))
376378
continue;
377379
}
378380
case 'n': special = '\n'; break;
381+
case 'r': special = '\r'; break;
379382
case 't': special = '\t'; break;
380383
case 'b': special = '\b'; break;
381384
}

src/test/com/mongodb/util/JSONTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public void testEscape1(){
200200
assertEquals( x , JSON.parse( x.toString() ) );
201201
assertEquals( raw , ((DBObject)JSON.parse( x.toString() ) ).get( "x" ) );
202202

203-
x = new BasicDBObject( "x" , "a\nb\bc\td" );
203+
x = new BasicDBObject( "x" , "a\nb\bc\td\re" );
204204
assertEquals( x , JSON.parse( x.toString() ) );
205205
}
206206

0 commit comments

Comments
 (0)