如何以 Java 中的 Json 模式以编程方式验证 Json 字符串?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35860456/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to programmatically validate Json string against a Json schema in Java?
提问by santro
I want to validate the format and structureof a JSON object against its JSON schema using Java. Where can I begin?
我想使用 Java 根据其 JSON 模式验证JSON 对象的格式和结构。我可以从哪里开始?
回答by Bandi Kishore
If you're looking for an online tool then you can try jsonschemalint-online-validator
如果您正在寻找在线工具,那么您可以尝试 jsonschemalint-online-validator
If you need to validate it using Java code then validate-json-against-schema-in-javashould help. It provides a step by step approach, along with sample code for reference.
如果您需要使用 Java 代码验证它,那么validate-json-against-schema-in-java应该会有所帮助。它提供了一个循序渐进的方法,以及示例代码以供参考。

