Tuesday 14 March 2017

json schema validators

http://wilddiary.com/validate-json-against-schema-in-java/

https://jsonschema.net/#/

http://jsonviewer.stack.hu/


sample json schema:
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "mytitle",
  "description": "my description",
  "type": "object",
  "required": [
    "data",
    "status"
  ],
  "properties": {
    "status": {
      "type": "number"
    },
    "data": {
      "type": "array",
      "minItems": 1,
      "additionalItems": true,
      "items": {
        "required": [
          "myStatus1",
          "myMediaPlanType",
          "myBudget",
          "myAccountID",
          "myAccountName",
          "myNotes",
          "myMediaPlans",
          "myAuditData",
          "myUsage1",
          "myMediaPlansCount",
          "myIsParentCrossBrandCampaign",
          "myCrossBrandIDs",
          "myCrossBrandChildCampaign",
          "myID",
          "myName"
        ],
        "myStatus1": {
          "type": "number"
        },
        "myMediaPlanType": {
          "type": "number"
        },
        "myBudget": {
          "type": "number"
        },
        "myAccountID": {
          "type": "number"
        },
        "myNotes": {
          "type": "string"
        },
        "myMediaPlans": {
          "type": "array"
        },
        "myAuditData": {
          "type": "object",
          "required": [
            "myCreatedByID",
            "myLastUpdatedByID",
            "myCreatedDate",
            "myLastUpdatedDate"
          ],
          "properties": {
            "myCreatedByID": {
              "type": "number"
            },
            "myLastUpdatedByID": {
              "type": "number"
            },
            "myCreatedDate": {
              "type": "string"
            },
            "myLastUpdatedDate": {
              "type": "string"
            }
          }
        },
        "myUsage1": {
          "type": "number"
        },
        "myMediaPlansCount": {
          "type": "number"
        },
        "myIsParentCrossBrandCampaign": {
          "type": "string"
        },
        "myCrossBrandIDs": {
          "type": "array"
        },
        "myCrossBrandChildCampaign": {
          "type": "array"
        },
        "myID": {
          "type": "number"
        },
        "myName": {
          "type": "string"
        }
      }
    }
  }
}