mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
support unicode escape sequence for json
like: {"name":"\u60a8\u597d"}
This commit is contained in:
@@ -151,6 +151,15 @@ public class ReadBasicJsonContext implements ReadJsonInterface {
|
||||
case '"':
|
||||
sb.append('"');
|
||||
break;
|
||||
case 'u':
|
||||
String msg = "EOF reading unicode value";
|
||||
char c1 = src.nextChar(msg);
|
||||
char c2 = src.nextChar(msg);
|
||||
char c3 = src.nextChar(msg);
|
||||
char c4 = src.nextChar(msg);
|
||||
char u = (char) Integer.parseInt(""+c1+c2+c3+c4, 16);
|
||||
sb.append(u);
|
||||
break;
|
||||
|
||||
default:
|
||||
sb.append('\\');
|
||||
|
||||
@@ -67,6 +67,10 @@ public class TestJsonSimple extends BaseTestCase {
|
||||
JsonElement jsonElement = InternalJsonParser.parse(s);
|
||||
Assert.assertNotNull(jsonElement);
|
||||
|
||||
JsonElement e3 = InternalJsonParser.parse("{\"name\":\"\\u60a8\\u597d\"}");
|
||||
|
||||
Assert.assertTrue(e3.evalString("name").length()==2);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user