同事们!我正在尝试使用jsonSchema来验证输入对象(Json作为字符串)。但是我对下一条消息有一个问题:com.networknt.schema.JsonSchemaException: java.lang.UnsupportedOperationException:没有适合于id的验证器。
我的模式如下:
```
{
"type" : "object",
"id" : "urn:jsonschema:x:x:x:x:x:x:x:x:Class_name",
"properties" : {
///objects
}
}and code with trying to validate:
```javascriptJsonSchemaFactory.getInstance(VersionFlag.V201909);工厂= JsonSchemaFactory工厂
InputStream stream=TestClass.class.getResourceAsStream("/file.json"); JsonSchema schema=factory.getSchema(stream); JsonNode node =mapper.convertToJsonNode(MyObject.builder().build()); Set<ValidationMessage> validationResult = schema.validate(node);My goal: if the fields are entered incorrectly, output a list of all these fields to the response. Please tell me what I'm doing wrong and are there other options for validation all json keys (not values)?
Current library:
```javascript <groupId>com.networknt</groupId> <artifactId>json-schema-validator</artifactId> <version>1.0.63</version> </dependency>谢谢!
发布于 2021-11-27 06:18:16
吉姆在正确的轨道上。
对于2019-09年草案(您看到它正在使用,JsonSchemaFactory.getInstance(VersionFlag.V201909)),id应该是$id。
这一改动是在草案6(以前的两个版本)时作出的。
https://stackoverflow.com/questions/70129741
复制相似问题