简体   繁体   English

如何在WSO2 ESB介体中验证JSON?

[英]How to validate JSON in WSO2 ESB mediator?

Does the validate mediator validate a message payload against a JSON schema? 验证中介器是否根据JSON模式验证消息有效负载?

If validate mediator does not validate JSON against a schema, what is the best workaround? 如果验证中介器未针对架构验证JSON,最佳解决方法是什么?

Currently there is no native JSON schema validation support in any ESB mediators. 当前,任何ESB介体中都没有本地JSON模式验证支持。 As a workaround, you will have to create an XSD structure as per your JSON payload and then use it in the validate mediator [1]. 解决方法是,您必须根据JSON有效负载创建一个XSD结构,然后在验证中介器中使用它[1]。

But however this feature is available in the road map [2]. 但是,此功能在路线图中是可用的[2]。

[1] - https://docs.wso2.com/display/ESB490/Validate+Mediator [1] -https://docs.wso2.com/display/ESB490/Validate+Mediator

[2] - https://wso2.org/jira/browse/ESBJAVA-4640 [2] -https://wso2.org/jira/browse/ESBJAVA-4640

You can simply do this using filter mediators. 您可以简单地使用过滤器介体来执行此操作。 use filter mediators for validate required keys/values in request. 使用过滤器中介来验证请求中的必需键/值。

for more details about filter mediators refer the below [1] wso2 doc 有关过滤器介体的更多详细信息,请参见下面的[1] wso2文档

[1] - https://docs.wso2.com/display/ESB480/Filter+Mediator [1] -https://docs.wso2.com/display/ESB480/Filter+Mediator

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM