मैं जेएसओएन स्कीमा का वर्णन करके एचटीएमएल फॉर्म से इनपुट को प्रमाणित करना चाहता हूं। मैं इसे सत्यापित करने के लिए गैरी कोर्ट के जेएसवी का उपयोग कर रहा हूं और यह लगातार एक त्रुटि देता है। मैंने अपनी स्कीमा की जांच के लिए JSON स्कीमा लिंट (jsonschemalint.com) का उपयोग किया। क्रोम स्कीमा लिंट में मुझे बताता है कि मेरी स्कीमा मान्य है, लेकिन फ़ायरफ़ॉक्स में, सफारी & ओपेरा वेबसाइट मुझे बताती है कि मेरी स्कीमा वैध JSON है लेकिन वैध JSON स्कीमा नहीं है। क्या कोई मेरी मदद कर सकता है। मेरी स्कीमा नीचे है।JSON स्कीमा का उपयोग कर फ़ॉर्म को कैसे सत्यापित करें?
अद्यतन 8/6/13 आपके सभी उत्तरों के लिए धन्यवाद। मेरा अद्यतन JSON (नीचे अपडेट किया गया) अब सभी ब्राउज़रों में मान्य है। हालांकि मैं अभी भी JSV से निम्न त्रुटि हो रही है:
Report {errors: Array[1], validated: Object, instance: JSONInstance, schema: JSONSchema, schemaSchema: JSONSchema…}
errors: Array[1]
0: Object
attribute: "type"
details: Array[1]
0: "object"
length: 1
__proto__: Array[0]
message: "Instance is not a required type"
schemaUri: "http://json-schema.org/draft-03/hyper-schema#"
uri: "urn:uuid:808fe74b-b0d0-4774-8975-289f105dfeaa#"
__proto__: Object
length: 1
__proto__: Array[0]
instance: JSONInstance
schema: JSONSchema
schemaSchema: JSONSchema
validated: Object
__proto__: Report
मुझे पहले का कहना है कि मैं त्रुटि संदेश गलत तरीके से व्याख्या की जा सकती है करते हैं। हालांकि मैं काफी हद तक निश्चित हूं कि यह उद्घाटन घुंघराले ब्रैकेट के बाद सीधे "type": "object"
लाइन का जिक्र कर रहा है। हालांकि "type": "object"
कुंजी: मान http://tools.ietf.org/html/draft-zyp-json-schema-03 पर ड्राफ्ट 03 spec का हिस्सा है। यह भ्रमित है क्योंकि जेएसओएन स्कीमा लिंट जेएसवी लाइब्रेरी का भी उपयोग करता है ... अब तक आपकी सभी मदद के लिए धन्यवाद।
{
"type": "object",
"$schema": "http://json-schema.org/draft-03/schema#",
"title": "FormValidation",
"description": "Describes the types of and valid inputs to a form generated via Form Creator",
"properties": {
"Air Temperature (C)": {
"type": "number",
"description": "Air Temperature measurement in centigrade.",
"required": false
},
"Ammonia": {
"type": "number",
"description": "Ammonia measurement at test site.",
"required": false
},
"Aquatic Life Present": {
"type": "string",
"description": "Are organisms such as fish or frogs living near the test site?",
"required": false
},
"Chlorophyll a": {
"type": "number",
"description": "Chlorophyll a measurement at test site.",
"required": false
},
"Conductivity": {
"type": "number",
"description": "Water conductivity measurement at test site.",
"required": false
},
"Date of Test": {
"type": "string",
"description": "Date the measurements were recorded.",
"required": true
},
"Dissolved Oxygen 1": {
"type": "number",
"description": "Disolved oxygen reading at first depth.",
"required": false
},
"Dissolved Oxygen 2": {
"type": "number",
"description": "Dissolved oxygen reading at second depth.",
"required": false
},
"Latitude": {
"type": "number",
"description": "Latitude of the measurement site in degrees.",
"required": true
},
"Longitude": {
"type": "number",
"description": "Longitude of the measurement site in degrees.",
"required": true
},
"Nitrates": {
"type": "number",
"description": "Nitrate measurement at test site.",
"required": false
},
"Orthophosphates": {
"type": "number",
"description": "Orthophosphate measurement at site of testing.",
"required": false
},
"Phosphates": {
"type": "number",
"description": "Phosphate reading at measurement site.",
"required": false
},
"Secchi Disk": {
"type": "number",
"description": "Secchi Disk depth reading at measurement site.",
"required": false
},
"Site Change": {
"type": "string",
"description": "Has the site undergone noticeable physical change since the last measuring event?",
"required": false
},
"Test Site": {
"type": "string",
"description": "Location where the measurements were recorded.",
"required": true
},
"Turbidity (ntu)": {
"type": "number",
"description": "Cloudiness or haziness of water, measured in Nephelometric Turbidity Units (NTU).",
"required": false
},
"Water Color or Odor": {
"type": "string",
"description": "Does the water have an strange colorations or emit a noticeable odor?",
"required": false
},
"Water Temperature (C)": {
"type": "number",
"description": "Water Temperature measurement in centigrade.",
"required": false
},
"pH": {
"type": "number",
"description": "pH measurement at test site.",
"required": false
}
}
}
क्या यह "आवश्यक" हो सकता है शुरुआत के दौरान केवल 'सत्य' या 'झूठा' हो सकता है? आप इसे कई गैर-बुलियन मूल्यों पर सेट कर चुके हैं। –
इसे भी आजमाएं: http://jsonlint.com/ –