赞
踩
{ "$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 } }}
[{"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":""}]
<!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>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。