@@ -50,7 +50,7 @@ public void testSimpleAltSources() throws Exception
50
50
assertEquals (1 , ((List <?>) ob ).size ());
51
51
}
52
52
53
- public void testParserFeatures () throws Exception
53
+ public void testParserFeaturesComments () throws Exception
54
54
{
55
55
final String JSON = "[ /* foo */ 7 ]" ;
56
56
// default won't accept comments, let's change that:
@@ -71,6 +71,36 @@ public void testParserFeatures() throws Exception
71
71
}
72
72
}
73
73
74
+ public void testParserFeaturesCtrlChars () throws Exception
75
+ {
76
+ String FIELD = "a\t b" ;
77
+ String VALUE = "\t " ;
78
+ String JSON = "{ " +quote (FIELD )+" : " +quote (VALUE )+"}" ;
79
+ Map <?, ?> result ;
80
+
81
+ // First: by default, unescaped control characters should not work
82
+ try {
83
+ result = MAPPER .readValue (JSON , Map .class );
84
+ fail ("Should not pass with defaylt settings" );
85
+ } catch (JsonParseException e ) {
86
+ verifyException (e , "Illegal unquoted character" );
87
+ }
88
+
89
+ // But both ObjectReader:
90
+ result = MAPPER .readerFor (Map .class )
91
+ .with (JsonReadFeature .ALLOW_UNESCAPED_CONTROL_CHARS )
92
+ .readValue (JSON );
93
+ assertEquals (1 , result .size ());
94
+
95
+ // and new mapper should work
96
+ ObjectMapper mapper2 = JsonMapper .builder ()
97
+ .enable (JsonReadFeature .ALLOW_UNESCAPED_CONTROL_CHARS )
98
+ .build ();
99
+ result = mapper2 .readerFor (Map .class )
100
+ .readValue (JSON );
101
+ assertEquals (1 , result .size ());
102
+ }
103
+
74
104
public void testNodeHandling () throws Exception
75
105
{
76
106
JsonNodeFactory nodes = new JsonNodeFactory (true );
0 commit comments