2016-10-05 12 views
0

JSONを使用してフォームを作成する必要があります。 最初の手順として、私はJSONをスキーマで検証する必要があります。ここで は私のJSONJSONスキーマの確認

"elements":{ 
     "textbox":{ 
      "name":{ 
      "type":"text", 
      "name":"textbox", 
      "label":"Enter Your Name", 
      "required":false, 
      "disabled":false, 
      "maxlength":"", 
      "pattern":"", 
      "readonly":false, 
      "value":"", 
      "autocomplete":"off" 
     }, 
     "school":{ 
      "type":"text", 
      "name":"textbox", 
      "label":"F", 
      "required":false, 
      "disabled":false, 
      "maxlength":"", 
      "pattern":"", 
      "readonly":false, 
      "value":"", 
      "autocomplete":"off" 
     } 

... ... ... }

だから、内部の "要素" の一部であり、それはJSONで誰の種類をテキストボックスを持っており、1フォームの作成のために「テキストボックス」内に任意の数のテキストボックスフィールドを与えることができます。

データを検証するためのJSONスキーマを作成する必要があります。具体的には、この特定の要素の部分の処理方法を知る必要があります。それを配列またはオブジェクト内の配列として定義するには? :(:/

答えて

0

まあ、私はあなたが配列としてtextboxを定義することを示唆しているんこの方法では、あなたの配列内のオブジェクトのためのさまざまなパラメータを設定することができ、その後、あなたはこの方法でデータを確認することができるだろう

を。このよう

{ 
    "$schema": "http://json-schema.org/draft-04/schema#", 
    "definitions": {}, 
    "id": "example", 
    "properties": { 
     "elements": { 
      "id": "/properties/elements", 
      "properties": { 
       "textbox": { 
        "id": "/properties/elements/properties/textbox", 
        "items": { 
         "id": "/properties/elements/properties/textbox/items", 
         "properties": { 
          "Parameter1": { 
           "id": "/properties/elements/properties/textbox/items/properties/Parameter1", 
           "type": "string" 
          }, 
          "Parameter2": { 
           "id": "/properties/elements/properties/textbox/items/properties/Parameter2", 
           "type": "number" 
          }, 
          "Parameter3": { 
           "id": "/properties/elements/properties/textbox/items/properties/Parameter3", 
           "type": "integer" 
          } 
         }, 
         "type": "object" 
        }, 
        "type": "array" 
       } 
      }, 
      "type": "object" 
     } 
    }, 
    "type": "object" 
} 

彼が望んで入力することができるなど、多くのテキストボックスとあなたはまだJSONを確認するために、同じスキーマを使用することができます

:ここでは

は、私が何を言っているかの小さな例です。

関連する問題