使用PHP进行JSON模式验证 [英] JSON schema validation with PHP

查看:80
本文介绍了使用PHP进行JSON模式验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何针对JSON模式验证JSON对象的PHP库?

Is there any PHP library that validates a JSON object against a JSON Schema?

推荐答案

关于jsonschemaphpv,尽管它维护得不是很好,但是我们经常使用它并且可以正常工作.这是js验证程序的端口.它具有针对php和 http://code.google.com/p的完整测试套件/jsonschema/.

About jsonschemaphpv, although it´s not very well maintained, we use it a lot and it works. It´s a port from the js validator. It has a full test suite that runs against the php and the http://code.google.com/p/jsonschema/.

猜猜是什么...它比js传递了更多的测试.至少在最后一次运行测试时.问题是该项目的结构不是很好,而且看起来很丑.但是,我保证您的程序非常稳定.它还允许您将关联数组验证为对象.

And guess what... It passes on more tests than the js. At least at the last time I run the tests. The thing is that the project is not very well structured and looks ugly. But I ensure you it´s very stable. It also allows you to validate associative arrays as objects either.

我首先用硒编写了测试.之后,我用phpunit编写了它们.我不确定phpunit测试是否存在.

I´ve written the tests in selenium first. After that I wrote them in phpunit. I´m not sure if the phpunit tests are there.

如果您尝试一下并且真的想要使用它,我可以使用phpunit测试在github上为其启动一个分支.

If you give it a try and really want to use it I can start a branch for it on github with the phpunit tests.

Bruno Reis(将js移植到php的人)

Bruno Reis (the person who ported the js to php)

这篇关于使用PHP进行JSON模式验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆