@@ -37,7 +37,8 @@ public static Stream<Arguments> appendTokens() {
37
37
Arguments .of (PathType .JSON_PATH , "$.foo" , "b.ar" , "$.foo['b.ar']" ),
38
38
Arguments .of (PathType .JSON_PATH , "$.foo" , "b~ar" , "$.foo['b~ar']" ),
39
39
Arguments .of (PathType .JSON_PATH , "$.foo" , "b/ar" , "$.foo['b/ar']" ),
40
- Arguments .of (PathType .JSON_PATH , "$" , "'" , "$['\' ']" ),
40
+ Arguments .of (PathType .JSON_PATH , "$" , "'" , "$['\\ '']" ),
41
+ Arguments .of (PathType .JSON_PATH , "$" , "b'ar" , "$['b\\ 'ar']" ),
41
42
Arguments .of (PathType .JSON_POINTER , "/foo" , "bar" , "/foo/bar" ),
42
43
Arguments .of (PathType .JSON_POINTER , "/foo" , "b.ar" , "/foo/b.ar" ),
43
44
Arguments .of (PathType .JSON_POINTER , "/foo" , "b~ar" , "/foo/b~0ar" ),
@@ -122,4 +123,36 @@ void testDoubleQuotes() throws JsonProcessingException {
122
123
assertEquals ("$['\" ']" , validationMessages .iterator ().next ().getPath ());
123
124
}
124
125
126
+ @ Test
127
+ void testSingleQuotes () throws JsonProcessingException {
128
+ ObjectMapper mapper = new ObjectMapper ();
129
+ SchemaValidatorsConfig schemaValidatorsConfig = new SchemaValidatorsConfig ();
130
+ schemaValidatorsConfig .setPathType (PathType .JSON_PATH );
131
+ /*
132
+ {
133
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
134
+ "type": "object",
135
+ "properties": {
136
+ "'": {
137
+ "type": "boolean"
138
+ }
139
+ }
140
+ }
141
+ */
142
+ JsonSchema schema = JsonSchemaFactory .getInstance (SpecVersion .VersionFlag .V201909 )
143
+ .getSchema (mapper .readTree ("{\n " +
144
+ " \" $schema\" : \" https://json-schema.org/draft/2019-09/schema\" ,\n " +
145
+ " \" type\" : \" object\" ,\n " +
146
+ " \" properties\" : {\n " +
147
+ " \" '\" : {\n " +
148
+ " \" type\" : \" boolean\" \n " +
149
+ " }\n " +
150
+ " }\n " +
151
+ "}" ), schemaValidatorsConfig );
152
+ // {"\"": 1}
153
+ Set <ValidationMessage > validationMessages = schema .validate (mapper .readTree ("{\" '\" : 1}" ));
154
+ assertEquals (1 , validationMessages .size ());
155
+ assertEquals ("$['\\ '']" , validationMessages .iterator ().next ().getPath ());
156
+ }
157
+
125
158
}
0 commit comments