2017-03-24 8 views
-1

タイトルが示すように、jsonファイルの有効なjsonスキーマの作成に問題があります。 jsonスキーマを作成してから、スキーマに対応するjsonデータファイルを作成します)。説明部分は母国語で書かれていますが、それは問題ではありません。オブジェクト "Paket"にプライマリオブジェクトの内部に1つ以上のオブジェクト "Paket"を再帰的に格納するオプションがある場合、問題が発生するようです。され、次の私のJSONスキーマ:JSONスキーマ検証がjsonデータで無効になっているため、オブジェクトを参照する方法がわからない

{ 
"$schema": "http://json-schema.org/schema#", 
"title": "Skladiste", 
"description": "Elektronski magacin visestrukog tipa za cuvanje podataka, to jest paketa sa svojim entitetima koji sadrze podatke.", 
"type": "object", 
"properties": { 
    "id": { 
     "description": "Jedinstveni identifikacioni broj skladista.", 
     "type": "integer" 
    }, 
    "name": { 
     "description": "Ime, to jest naziv, skladista.", 
     "type": "string" 
    }, 
    "paketi": { 
     "description": "Lista paketa.", 
     "type": "array", 
     "items": { 
      "title": "Paket", 
      "description": "Virtuelna fascikla koja moze da sadrzi entitete, ali i druge pakete.", 
      "type": "object", 
      "properties": { 
       "id": { 
        "description": "Jedinstveni identifikacioni broj paketa.", 
        "type": "integer" 
       }, 
       "name": { 
        "description": "Ime, to jest naziv paketa.", 
        "type": "string" 
       }, 
       "paketi": { 
        "description": "Niz paketa unutar paketa.", 
        "type": "array", 
        "items": { 
         "type": "Paket" 
        } 
       }, 
       "entiteti": { 
        "description": "Niz entiteta.", 
        "type": "array", 
        "items": { 
         "title": "Entitet", 
         "description": "Objekat u sistemu u kome se skladiste atributi, to jest sadrzioci podataka i informacija.", 
         "type": "object", 
         "properties": { 
          "id": { 
           "description": "Jedinstven identifikacioni broj entiteta.", 
           "type": "number" 
          }, 
          "name": { 
           "description": "Ime, to jest naziv entiteta.", 
           "type": "integer" 
          }, 
          "atributi": { 
           "description": "Niz atributa.", 
           "type": "array", 
           "items": { 
            "title": "Atribut", 
            "description": "Objekat koji sadrzi, to jest skladisti informacije i podatke.", 
            "type": "object", 
            "properties": { 
             "id": { 
              "type": "integer" 
             }, 
             "name": { 
              "type": "string" 
             }, 
             "type": { 
              "enum": [ 
               "String", 
               "Int", 
               "DateTime" 
              ] 
             } 
            }, 
            "required": ["id", "name", "type"] 
           } 
          }, 
          "relacije": { 
           "description": "Niz relacija.", 
           "type": "array", 
           "items": { 
            "title": "Relacija", 
            "description": "Veza koja ukazuje na bliskost dva entiteta.", 
            "type": "object", 
            "properties": { 
             "id": { 
              "type": "integer" 
             }, 
             "name": { 
              "type": "string" 
             }, 
             "ReferenciranEntitet": { 
              "type": "string" 
             } 
            }, 
            "required": ["id", "name", "ReferenciranEntitet"] 
           } 
          } 
         }, 
         "required": ["id", "name"] 
        } 
       } 
      }, 
      "required": ["id", "name"] 
     } 
    } 
}, 
"required": ["id", "name"] 

}ここ

とは、私のJSONデータファイル

{ 
"id":"1", 
"name": "KpopGrupe", 
"paketi": [ 
    { 
     "id": "1", 
     "name": "Seventeen", 
     "paketi": [ 
      { 
       "id": "1", 
       "name": "HipHopTim", 
       "entiteti": [ 
        { 
         "id": "1", 
         "name": "ChoiSungCheol", 
         "atributi": [ 
          { 
           "id": "1", 
           "name": "IzvodjackoIme", 
           "type": "String" 
          }, 
          { 
           "id": "2", 
           "name": "Nacionalnost", 
           "type": "String" 
          }, 
          { 
           "id": "3", 
           "name": "DatumRodjenja", 
           "type": "DateTime" 
          } 
         ], 
         "relacije": [ 
          { 
           "id": "1", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "JeonWonwoo" 
          }, 
          { 
           "id": "2", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "KimMingyu" 
          }, 
          { 
           "id": "3", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "HansolVernonChoi" 
          } 
         ] 
        }, 
        { 
         "id": "2", 
         "name": "JeonWonwoo", 
         "atributi": [ 
          { 
           "id": "1", 
           "name": "IzvodjackoIme", 
           "type": "String" 
          }, 
          { 
           "id": "2", 
           "name": "Nacionalnost", 
           "type": "String" 
          }, 
          { 
           "id": "3", 
           "name": "DatumRodjenja", 
           "type": "DateTime" 
          } 
         ], 
         "relacije": [ 
          { 
           "id": "1", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "ChoiSungCheol" 
          }, 
          { 
           "id": "2", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "KimMingyu" 
          }, 
          { 
           "id": "3", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "HansolVernonChoi" 
          } 
         ] 
        }, 
        { 
         "id": "3", 
         "name": "KimMingyu", 
         "atributi": [ 
          { 
           "id": "1", 
           "name": "IzvodjackoIme", 
           "type": "String" 
          }, 
          { 
           "id": "2", 
           "name": "Nacionalnost", 
           "type": "String" 
          }, 
          { 
           "id": "3", 
           "name": "DatumRodjenja", 
           "type": "DateTime" 
          } 
         ], 
         "relacije": [ 
          { 
           "id": "1", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "ChoiSungCheol" 
          }, 
          { 
           "id": "1", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "JeonWonwoo" 
          }, 
          { 
           "id": "1", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "HansolVernonChoi" 
          } 
         ] 
        }, 
        { 
         "id": "4", 
         "name": "HansolVernonChoi", 
         "atributi": [ 
          { 
           "id": "1", 
           "name": "IzvodjackoIme", 
           "type": "String" 
          }, 
          { 
           "id": "2", 
           "name": "Nacionalnost", 
           "type": "String" 
          }, 
          { 
           "id": "3", 
           "name": "DatumRodjenja", 
           "type": "DateTime" 
          } 
         ], 
         "relacije": [ 
          { 
           "id": "1", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "ChoiSungCheol" 
          }, 
          { 
           "id": "2", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "JeonWonwoo" 
          }, 
          { 
           "id": "3", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "KimMingyu" 
          } 
         ] 
        } 
       ] 
      }, 
      { 
       "id": "2", 
       "name": "VokalniTim", 
       "entiteti": [ 
        { 
         "id": "1", 
         "name": "YoonJungHan", 
         "atributi": [ 
          { 
           "id": "1", 
           "name": "IzvodjackoIme", 
           "type": "String" 
          }, 
          { 
           "id": "2", 
           "name": "Nacionalnost", 
           "type": "String" 
          }, 
          { 
           "id": "3", 
           "name": "DatumRodjenja", 
           "type": "DateTime" 
          } 
         ], 
         "relacije": [ 
          { 
           "id": "1", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "HongJisoo" 
          }, 
          { 
           "id": "2", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "LeeJihun" 
          }, 
          { 
           "id": "3", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "LeeSeokmin" 
          }, 
          { 
           "id": "4", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "BooSeungKwan" 
          } 
         ] 
        }, 
        { 
         "id": "2", 
         "name": "HongJisoo", 
         "atributi": [ 
          { 
           "id": "1", 
           "name": "IzvodjackoIme", 
           "type": "String" 
          }, 
          { 
           "id": "2", 
           "name": "Nacionalnost", 
           "type": "String" 
          }, 
          { 
           "id": "3", 
           "name": "DatumRodjenja", 
           "type": "DateTime" 
          } 
         ], 
         "relacije": [ 
          { 
           "id": "1", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "YoonJungHan" 
          }, 
          { 
           "id": "2", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "LeeJihun" 
          }, 
          { 
           "id": "3", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "LeeSeokmin" 
          }, 
          { 
           "id": "4", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "BooSeungKwan" 
          } 
         ] 
        }, 
        { 
         "id": "3", 
         "name": "LeeJihun", 
         "atributi": [ 
          { 
           "id": "1", 
           "name": "IzvodjackoIme", 
           "type": "String" 
          }, 
          { 
           "id": "2", 
           "name": "Nacionalnost", 
           "type": "String" 
          }, 
          { 
           "id": "3", 
           "name": "DatumRodjenja", 
           "type": "DateTime" 
          } 
         ], 
         "relacije": [ 
          { 
           "id": "1", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "YoonJungHan" 
          }, 
          { 
           "id": "2", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "HongJisoo" 
          }, 
          { 
           "id": "3", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "LeeSeokmin" 
          }, 
          { 
           "id": "4", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "BooSeungKwan" 
          } 
         ] 
        }, 
        { 
         "id": "4", 
         "name": "LeeSeokmin", 
         "atributi": [ 
          { 
           "id": "1", 
           "name": "IzvodjackoIme", 
           "type": "String" 
          }, 
          { 
           "id": "2", 
           "name": "Nacionalnost", 
           "type": "String" 
          }, 
          { 
           "id": "3", 
           "name": "DatumRodjenja", 
           "type": "DateTime" 
          } 
         ], 
         "relacije": [ 
          { 
           "id": "1", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "YoonJungHan" 
          }, 
          { 
           "id": "2", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "HongJisoo" 
          }, 
          { 
           "id": "3", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "LeeJihun" 
          }, 
          { 
           "id": "4", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "BooSeungKwan" 
          } 
         ] 
        }, 
        { 
         "id": "5", 
         "name": "BooSeungKwan", 
         "atributi": [ 
          { 
           "id": "1", 
           "name": "IzvodjackoIme", 
           "type": "String" 
          }, 
          { 
           "id": "2", 
           "name": "Nacionalnost", 
           "type": "String" 
          }, 
          { 
           "id": "3", 
           "name": "DatumRodjenja", 
           "type": "DateTime" 
          } 
         ], 
         "relacije": [ 
          { 
           "id": "1", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "YoonJungHan" 
          }, 
          { 
           "id": "2", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "HongJisoo" 
          }, 
          { 
           "id": "3", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "LeeJihun" 
          }, 
          { 
           "id": "4", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "LeeSeokmin" 
          } 
         ] 
        } 
       ] 
      }, 
      { 
       "id": "3", 
       "name": "PlesniTim", 
       "entiteti": [ 
        { 
         "id": "1", 
         "name": "WenJunhui", 
         "atributi": [ 
          { 
           "id": "1", 
           "name": "IzvodjackoIme", 
           "type": "String" 
          }, 
          { 
           "id": "2", 
           "name": "Nacionalnost", 
           "type": "String" 
          }, 
          { 
           "id": "3", 
           "name": "DatumRodjenja", 
           "type": "DateTime" 
          } 
         ], 
         "relacije": [ 
          { 
           "id": "1", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "KwonSoonyoung" 
          }, 
          { 
           "id": "2", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "XuMinghao" 
          }, 
          { 
           "id": "3", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "LeeChan" 
          } 
         ] 
        }, 
        { 
         "id": "2", 
         "name": "KwonSoonyoung", 
         "atributi": [ 
          { 
           "id": "1", 
           "name": "IzvodjackoIme", 
           "type": "String" 
          }, 
          { 
           "id": "2", 
           "name": "Nacionalnost", 
           "type": "String" 
          }, 
          { 
           "id": "3", 
           "name": "DatumRodjenja", 
           "type": "DateTime" 
          } 
         ], 
         "relacije": [ 
          { 
           "id": "1", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "WenJunhui" 
          }, 
          { 
           "id": "2", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "XuMinghao" 
          }, 
          { 
           "id": "3", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "LeeChan" 
          } 
         ] 
        }, 
        { 
         "id": "3", 
         "name": "XuMinghao", 
         "atributi": [ 
          { 
           "id": "1", 
           "name": "IzvodjackoIme", 
           "type": "String" 
          }, 
          { 
           "id": "2", 
           "name": "Nacionalnost", 
           "type": "String" 
          }, 
          { 
           "id": "3", 
           "name": "DatumRodjenja", 
           "type": "DateTime" 
          } 
         ], 
         "relacije": [ 
          { 
           "id": "1", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "WenJunhui" 
          }, 
          { 
           "id": "2", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "KwonSoonyoung" 
          }, 
          { 
           "id": "3", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "LeeChan" 
          } 
         ] 
        }, 
        { 
         "id": "4", 
         "name": "LeeChan", 
         "atributi": [ 
          { 
           "id": "1", 
           "name": "IzvodjackoIme", 
           "type": "String" 
          }, 
          { 
           "id": "2", 
           "name": "Nacionalnost", 
           "type": "String" 
          }, 
          { 
           "id": "3", 
           "name": "DatumRodjenja", 
           "type": "DateTime" 
          } 
         ], 
         "relacije": [ 
          { 
           "id": "1", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "WenJunhui" 
          }, 
          { 
           "id": "2", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "KwonSoonyoung" 
          }, 
          { 
           "id": "3", 
           "name": "ClanIstePodgrupe", 
           "referenciranEntitet": "XuMinghao" 
          } 
         ] 
        } 
       ] 

      } 
     ] 
    } 
] 

}

私はバリにそれを置くとき、エラー箇所にありますオブジェクトPaket内の配列リストpaketiが別のオブジェクト型Paketを含む部分。明らかにそれはしませんが、それは私の頭の中でうまくいくようです。誰もが思考の私の欠陥を指摘することができますか?前もって感謝します。 :D

答えて

0

主な問題は"type": "Paket"です。それは有効ではありません。恐らく、サブスキーマを"title": "Paket"で参照しようとしています。このようなものが欲しい。その変更に伴い

{ 
    "$schema": "http://json-schema.org/schema#", 
    "title": "Skladiste", 
    "description": "Elektronski magacin visestrukog tipa za cuvanje podataka, to jest paketa sa svojim entitetima koji sadrze podatke.", 
    "type": "object", 
    "definitions": { 
    "paket": { 
     "title": "Paket", 
     ... snip ... 
     "properties": { 
     ... snip ... 
     "paketi": { 
      "description": "Niz paketa unutar paketa.", 
      "type": "array", 
      "items": { "$ref": "#/definitions/paket" } <-- self reference 
     }, 
     ... snip ... 
     } 
     ... snip ... 
    } 
    }, 
    "properties": { 
    "id": { 
     "description": "Jedinstveni identifikacioni broj skladista.", 
     "type": "integer" 
    }, 
    "name": { 
     "description": "Ime, to jest naziv, skladista.", 
     "type": "string" 
    }, 
    "paketi": { 
     "description": "Lista paketa.", 
     "type": "array", 
     "items": { "$ref": "#/definitions/paket" } <-- definition reference 
    } 
    }, 
    "required": ["id", "name"] 
} 

有効なスキーマを持っているが、あなたはまだあなたのスキーマがあなたのデータと一致していないいくつかの場所を持っています。たとえば、 "id"プロパティは "整数"または "数値"型として定義されますが、データはすべて "id"を文字列として表現します"1""1"は、JSONスキーマの整数または数値ではありません。それは文字列です。私はあなたにそのような小さな問題をきれいにするために残しておきます。

-1

あなたのスキーマにはいくつかのエラーがあります。タイプは整数ではなく数値でなければなりません。

以下のスキーマを参照してください、

{ 
"$schema": "http://json-schema.org/schema#", 
"title": "Skladiste", 
"description": "Elektronski magacin visestrukog tipa za cuvanje podataka, to jest paketa sa svojim entitetima koji sadrze podatke.", 
"type": "object", 
"properties": { 
    "id": { 
     "description": "Jedinstveni identifikacioni broj skladista.", 
     "type": "number" 
    }, 
    "name": { 
     "description": "Ime, to jest naziv, skladista.", 
     "type": "string" 
    }, 
    "paketi": { 
     "description": "Lista paketa.", 
     "type": "array", 
     "items": { 
      "title": "Paket", 
      "description": "Virtuelna fascikla koja moze da sadrzi entitete, ali i druge pakete.", 
      "type": "object", 
      "properties": { 
       "id": { 
        "description": "Jedinstveni identifikacioni broj paketa.", 
        "type": "number" 
       }, 
       "name": { 
        "description": "Ime, to jest naziv paketa.", 
        "type": "string" 
       }, 
       "paketi": { 
        "description": "Niz paketa unutar paketa.", 
        "type": "array", 
        "items": { 
         "type": "object" 
        } 
       }, 
       "entiteti": { 
        "description": "Niz entiteta.", 
        "type": "array", 
        "items": { 
         "title": "Entitet", 
         "description": "Objekat u sistemu u kome se skladiste atributi, to jest sadrzioci podataka i informacija.", 
         "type": "object", 
         "properties": { 
          "id": { 
           "description": "Jedinstven identifikacioni broj entiteta.", 
           "type": "number" 
          }, 
          "name": { 
           "description": "Ime, to jest naziv entiteta.", 
           "type": "integer" 
          }, 
          "atributi": { 
           "description": "Niz atributa.", 
           "type": "array", 
           "items": { 
            "title": "Atribut", 
            "description": "Objekat koji sadrzi, to jest skladisti informacije i podatke.", 
            "type": "object", 
            "properties": { 
             "id": { 
              "type": "integer" 
             }, 
             "name": { 
              "type": "string" 
             }, 
             "type": { 
              "enum": [ 
               "String", 
               "Int", 
               "DateTime" 
              ] 
             } 
            }, 
            "required": ["id", "name", "type"] 
           } 
          }, 
          "relacije": { 
           "description": "Niz relacija.", 
           "type": "array", 
           "items": { 
            "title": "Relacija", 
            "description": "Veza koja ukazuje na bliskost dva entiteta.", 
            "type": "object", 
            "properties": { 
             "id": { 
              "type": "integer" 
             }, 
             "name": { 
              "type": "string" 
             }, 
             "ReferenciranEntitet": { 
              "type": "string" 
             } 
            }, 
            "required": ["id", "name", "ReferenciranEntitet"] 
           } 
          } 
         }, 
         "required": ["id", "name"] 
        } 
       } 
      }, 
      "required": ["id", "name"] 
     } 
    } 
}, 
"required": ["id", "name"] 
} 

ともJSONデータで同じに変更します。

関連する問題