简体   繁体   English

JSON-验证表单数据

[英]JSON - Validate Form Data

I used xml earlier and learning JSON now. 我以前使用过xml,现在学习JSON。 To restrict the user to enter garbage values for form fields such as address etc, in XML we can define a complex object in schema file. 为了限制用户为表单字段(例如地址等)输入垃圾值,在XML中,我们可以在模式文件中定义一个复杂的对象。 But using JSON How can do that? 但是使用JSON怎么办呢? JSON accepts any data from the user. JSON接受来自用户的任何数据。 Could any one please provide me ideas or an example code? 有人可以提供我的想法或示例代码吗?

Thanks in Advance. 提前致谢。

it is possible to do validation with schemas in JSON : 可以使用JSON中的模式进行验证:

http://en.wikipedia.org/wiki/JSON#JSON_Schema http://en.wikipedia.org/wiki/JSON#JSON_Schema

depending on what you need to validate : 根据您需要验证的内容:

http://json-schema.org/latest/json-schema-validation.html http://json-schema.org/latest/json-schema-validation.html

Online tool for testing : 在线测试工具:

http://www.jsonschema.net/ http://www.jsonschema.net/

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

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