- 浏览: 1074916 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (290)
- php (65)
- javascript (36)
- html5 (31)
- thinkphp (9)
- mysql (16)
- jquery (13)
- node.js (9)
- css (9)
- android 开发 (8)
- flex (5)
- java (3)
- apache (8)
- linux (8)
- git (5)
- web (5)
- wordpress (9)
- mongodb (2)
- redis (5)
- yaf (6)
- python (4)
- big data (1)
- sphinx (1)
- html (1)
- bootstrap (1)
- vue (1)
- laravel (1)
- test (0)
最新评论
-
July01:
推荐用StratoIO打印控件,支持网页、URL、图片、PD、 ...
如何解决非IE浏览器的web打印 -
flashbehappy:
同一个视频,有mp4,ogg两种格式的。在chrome,fir ...
firefox chrom safari 对video标签的区别 -
xmdxzyf:
可以在网站(www.sosoapi.com)上试下在线表单方式 ...
用swagger-php/ui做API测试 -
flex_莫冲:
a2631500 写道"看了源码,设置Backbon ...
backbone与php交互 -
a2631500:
"看了源码,设置Backbone.emulateJS ...
backbone与php交互
为了检测API返回的数据结构是否正确,刚好chrome的插件postman可以做这件事。其实它用的也是tv4的库来验证。又找了一些开源的验证工具。如下
在线验证工具:
只支持http://json-schema.org/draft-03/schema#
https://json-schema-validator.herokuapp.com/
schema
json:
dojo json schema:
http://pro.jsonlint.com/
在postman中的json validate
参考资料:
http://www.asbjornenge.com/wwc/json_schema.html
http://json-schema.org/documentation.html
postman 用的验证工具
https://github.com/geraintluff/tv4
http://www.getpostman.com/docs/
在线验证工具:
只支持http://json-schema.org/draft-03/schema#
https://json-schema-validator.herokuapp.com/
schema
{ "$schema": "http://json-schema.org/draft-03/schema#", "title": "App", "description": "APP LIST", "type": "array", "properties":{ "appID": { "type": "string", "required":true }, "appName":{ "type": "string", "required":true }, "appCaption":{ "type": "string", "required":true }, "icon":{ "type":"string", "required":true } } }
json:
[{"appID":"1","appName":"push","appCaption":"push ","icon":""},{"appID":"52","appName":"Sample(\u4e13\u7528)","appCaption":"Sample(\u4e13\u7528)","icon":""},{"appID":"64","appName":"\u65b0\u73af\u5883\u6d4b\u8bd5dddd","appCaption":"\u65b0\u73af\u5883\u6d4b\u8bd5","icon":""}]
dojo json schema:
http://pro.jsonlint.com/
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="chrome=1" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>dojox.json.schema example</title> <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.7.0/dojo/dojo.js" type="text/javascript"></script> <script type="text/javascript"> require(["dojox/json/schema"], function() { // Object to validate var successObj = { "foo" : "bar" }; var failureObj = { "foo" : 1234 }; // Schema var schema = { "type": "object", "properties" : { "foo" : { "type" : "string" }, "icon":{ } } }; // Run validation, which should succeed // Change this line to use failureObj to see the failure case var result = dojox.json.schema.validate(successObj, schema); // Check results if (result.valid) { // Success, do something alert("Object is valid"); } else { // Failure - extract the errors array var errorArr = result.errors; alert("property : " + errorArr[0].property + "\nmessage : " + errorArr[0].message); } }); </script> </head> <body> <h1>Example use of dojox.json.schema</h1> <p> Due to its use of the Dojo CDN distribution on google.com, this HTML file MUST be accessed through an HTTP server such as Apache. file:/// URIs won't work.' </p> </body> </html>
在postman中的json validate
tests["Status code is 200"] = responseCode.code === 200; var data = JSON.parse(responseBody); tests["status"] = data.status === true; tests["info"] = data.info === "success"; var appData = data.data; tests['appCount'] = appData.length === 3; var schema = { "$schema": "http://json-schema.org/draft-04/schema#", "title": "App", "description": "APP LIST", "type": "object", "properties":{ "appID": { "type": "string" }, "appName":{ "type": "string" }, "appCaption":{ "type": "string" }, "icon":{ "type":"string", "required":true, "pattern":"^http://" } } }; $.each(appData, function (i) { var app = this; tests['appName'+i] = tv4.validate(app, schema); })
参考资料:
http://www.asbjornenge.com/wwc/json_schema.html
http://json-schema.org/documentation.html
postman 用的验证工具
https://github.com/geraintluff/tv4
http://www.getpostman.com/docs/
发表评论
-
使用BOOTSTRAP创建没有遮罩的可移动dialog
2017-01-16 12:00 1564bootstrap是个很流行的前端工具。我想做个没有遮罩的di ... -
富文本编辑器推荐
2016-10-26 16:03 2385website: https://www.froala.com ... -
一些比较特别的js库和框架
2016-08-11 14:05 604http://www.meedee.cn/2016/06/07 ... -
Javascript的变量与delete操作符
2016-08-11 14:02 436来自:http://www.meedee.cn/2 ... -
uploadifive上傳插件的使用
2015-02-17 18:07 30721 自定義上傳錯誤/進度提示位置 'queueID':&quo ... -
来自yahoo的web优化规则(YSLOW的23条军规)
2014-09-11 17:53 1611https://developer.yahoo.com/per ... -
<a>的href中添加js函数的写法
2014-03-18 15:54 1215参考资料: http://www.cnblogs.com/op ... -
使用backbonejs的router功能
2014-01-02 12:13 919来源: http://css.dzone.com/articl ... -
初次seajs使用
2013-11-22 14:11 2945第一次用报了$=null的错 ... -
Javascript:history.go()和history.back()的用法和区别
2013-08-02 14:38 37531Javascript:history.go()和history ... -
JAVASCRIPT常用函数集合
2013-07-23 15:01 9271、删除数组某项 // Array Remove - By ... -
JS判断一个数组中是否有重复值的三种方法
2013-07-18 09:52 2203参考 http://superivan.iteye.com/b ... -
多DOM操作的性能优化
2013-07-15 17:32 942今天发现DOM操作很多,且是显示隐藏操作,性能是非常差的。一个 ... -
SafariJSRef safary开发指南
2013-07-10 11:30 889针对safari的js和css开发指南。 https://de ... -
js获取屏幕可视区域
2013-06-04 11:10 925IE: document.body.offsetWidth, ... -
backbone 的delegateEvent用法
2013-05-24 10:37 4624這篇文章記錄關於 Backbone delegateEvent ... -
post的数据参数内容包含&如何如何处理
2013-01-17 23:37 2452这星期测试人员提交了一个bug,表单保存的数据不完整。查了一下 ... -
javascript 同zindex的重叠div如何处理事件关系
2012-11-15 11:43 6480在一个页面中有3个独立的div,不存在嵌套层次关系。3个div ... -
jquery easyui 操作总结
2012-10-29 12:32 288041、dialog $("#dialog-form& ... -
javascript浮点运算偏差的成因及解决方法
2012-10-25 10:26 2461原文地址:http://eatpockyboy.blog.16 ...
相关推荐
grunt-jsonschema-validate v0.1.3 根据 JSON 模式验证 JSON 文件的 Grunt 任务 入门 这个插件需要 Grunt >=0.4.0 如果您以前没有使用过 ,请务必查看指南,因为它解释了如何创建以及安装和使用 Grunt 插件。 熟悉...
JSONSchema.swift 不支持远程引用 。 安装 JSONSchema 可以通过安装。 pod 'JSONSchema' 用法 import JSONSchema try JSONSchema. validate ([ " name " : " Eggs " , " price " : 34.99 ], schema : [ " type ...
>> > from jsonschema import validate >> > # A sample schema, like what we'd get from json.load() >> > schema = { ... "type" : "object" , ... "properties" : { ... "price" : { "type" : "number" }, ... ...
jsonschema-validate-default 只是一个基于jsonschema库的小库,可让您测试对象是否有效以及是否将其与默认数据结合使用范例懒惰的const validate = require ( 'djsv' ) ;// create your schemaconst json = { "type...
esbuild-plugin-jsonschema 使用esbuild在导入时编译和打包JSON模式定义 安装 该软件包以@offen/esbuild-plugin-jsonschema形式发布到npm: npm install @offen/esbuild-plugin-jsonschema -D 用法 在默认配置中,...
======================== jsonschema-errorprinter 库的验证错误 Pretty-Printer。 check_json函数包装了validate()并且在 ValidationError 异常的情况下,返回一个包含漂亮打印错误报告的字符串。 例子: >> > ...
json模式类 通过ajv包包括JSON Schema验证的基类。正在安装npm install json-schema-class --save输入import SchemaClass from 'json-schema-class' ;SchemaClass公共方法您应该能够根据当前模式草案验证类本身。 您...
egg-jsonschema 基于 提供数据校验方法。 安装 $ npm i egg-jsonschema --save 配置 // {app_root}/config/plugin.js exports.jsonschema = { enable: true, package: 'egg-jsonschema', }; 使用方法 ctx.validate...
validate-json-schema-form 使用验证表单。 安装 $ npm install validate-json-schema-form 用法 < form id =" signup-form " > < input name =" username " type =" text " placeholder =" username " ...
chat.freenode.net上的#ruby-json-schema 2.0.0版升级说明 请注意,默认情况下,升级到2.0.0版将使用Draft-04,因此未使用$schema关键字声明验证器的$schema现在将使用Draft-04而不是Draft-03。 这是主要版本升级的...
本文实例讲述了php使用json-schema模块实现json校验。分享给大家供大家参考,具体如下: 客户端和服务端的http信息传递,采用...新建一个schema文件,如:schema.json { type: object, properties: { firstName:
public boolean validate(String input) { input = input.trim(); boolean ret = valid(input); return ret; } private boolean valid(String input) { if ("".equals(input)) return true; boolean ret =...
ramldt2jsonschema CLI和库可将RAML 1.0数据类型转换为JSON模式,然后再转换回。 在使用 。 用法 全球(CLI) npm install -g ramldt2jsonschema 这将安装两个命令行工具: dt2js :RAML数据类型<> JSON模式 ...
该库能够在运行时验证JSON-Schema,还可以发出已验证数据的类型定义。 这意味着,如果您使用我们的JSON模式构建器定义数据,则可以自动获得这些类型的TypeScript安全性。 例子 模式生成: await validator . ...
当使用unicode代理对时,它通过了整个JSONSchema v4测试套件,但remoteRefs和maxLength / minLength除外。安装npm install --save is-my-json-valid用法只需传递一个模式即可对其进行编译var validator = require ...
# use a virtual environment (optional)virtualenv venvsource venv/bin/activatepip install jsonschema 如果在运行脚本时看到诸如“没有名为jsonschema的模块”之类的错误,则说明您未正确安装jsonschema软件包...
注意力!...var validate = require('plexus-validate'); var Form = require('plexus-form'); var schema = { title : "My pretty form", description: "Declarative pure data DSLs are the best.",
可能不支持较新的草稿功能。 请参阅以获取所有现有草稿的概述。 有关更多详细信息,请参见 。 安装 图书馆 ...composer require justinrainbow/json-schema ...$ validator = new JsonSchema \ Validator ;
Swagger模式验证器 该库针对Swagger 2规范的definitions部分中definitions模型验证JSON对象。 InputStream spec = getClass() . getResourceAsStream( " mySpec.yaml " );SwaggerValidator validator = ...
JSON验证实用程序 ... validate example.json example_schema.json 库功能使用 验证(dataFile,schemaFile,refFiles,jsdbFile,回调) dataFile String JSON数据文件的文件名(路径可选) schemaFile Str