java根据xsd验证json文件,针对XML Schema(XSD)验证JSON

Is it possible to validate JSON an XSD in Java? I have an application where I receive JSON response, and I would like to validate it against existing XSD. Another part of my application uses XML, which is why it would be easiest if they both could validate against the existing XSD.

解决方案

No, XML Schema (XSD) is for validating XML; to validate JSON, see JSON Schema.

I recommend generating schemas by hand for full understanding and full control over the constraints. However, here are some automated tools that can jumpstart the process:

To convert from JSON Schema to XSD, see jsons2xsd.

To convert from XSD to JSON Schema, see Jsonix Schema Compiler.

Related and also very useful:

To parse from XML to JSON (unmarshal) or serialize JSON to XML

(marshal), see JSONIX.

For a list of implementations, including validators in various languages, see JSON-Schema Implementations.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值