5

それを記述する JSON スキーマを使用して、HTML フォームからの入力を検証したいと考えています。Gary Court の JSV を使用して検証していますが、一貫してエラーが返されます。JSON Schema Lint (jsonschemalint.com) を使用してスキーマをチェックしました。Chrome Schema Lint では、スキーマが有効であることがわかりますが、Firefox、Safari、および Opera では、Web サイトでスキーマが有効な JSON であるが有効な JSON スキーマではないことがわかります。誰でも私を助けることができますか?私のスキーマは以下のとおりです。

UPDATE 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"ただし、これは中括弧の直後の行を参照していると確信しています。ただし、 key:value はhttps://datatracker.ietf.org/doc/html/draft-zyp-json-schema-03"type": "object"のドラフト 03 仕様の一部です。JSON Schema Lint は JSV ライブラリも使用するため、これは混乱を招きます...これまでご協力いただきありがとうございました。

{
"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
    }
}
}
4

2 に答える 2