Just getting started with JSON Schema. I understood the part where one can define a schema and validate a JSON against this schema.
What is not clear is how I can define different schema for different JSON objects (say Events) and still validate my incoming JSON against the appropriate schema?
Consider the following 2 events:
{
"type": "A",
"a": 1
}
{
"type": "B",
"b": 1,
"b1": 2
}
For event type A, there is one property a where as for event type B there are two other properties b and b1. So if I have 2 separate schema for each of the types A and B, am I supposed to check the type of the incoming event JSON and then pick the correct schema to validate against? Or is there any other simpler way?
The reason for this ask is, there are situations where I have multiple JSON objects without any identifying type property. I am wondering if there is any way to see my JSON is valid against any of the schemas.