I've tried to use JSON Schema and the big gap I couldn't figure was how to handle polymorphism.
That is, if I have a case where object
{
"Foo": {
"Type":"Fred"
"Bar":1
"Baz":2
"Quux":2
}
}
and the object {
"Foo": {
"Type":"Waldo"
"Bar":1
"Corge":2
"Xyzzy":7
}
}
are both valid, without just allowing any object members or allowing the union of their members.I did a hack by multiplexing the types into a child-object, but that was ugly and clumsy.
In XSD or any statically-typed programming language I could handle this trivially using types and polymorphism, because "Fred" and "Waldo" would be different types.
But I can't figure out how to do that in Json Schema.