json schema validation in java [closed]

2019-03-07 10:43发布

问题:

I want to validate the json file using schema. How to do that.

{
    "Book_information: [{
                      "BookName": "English",
                      "ConfigFile": "English.json",
                      "dependsOn": "Tamil",
                      "maxPurchase": "1",
                      "BookInformation": {
                            "name": "English",
                                                "id": "English-1"
                                }

                }, {
                                "BookName": "Tamil",
                                "ConfigFile": "Tamil.json",
                                "maxPurchase": "3",
                                "BookInformation": {
                                                "name": "Tamil",
                                                "id": "Tamil-1"
                                }

                }]
}

回答1:

If you're looking for an online tool then you can try jsonschemalint-online-validator

If you need to validate it using Java code then validate-json-against-schema-in-java should help. It provides a step by step approach, along with sample code for reference.