What you describe is called a JSON schema.
For example the JSON schema for the following JSON:
{
"first" : "Fred",
"last" : "Flintstone"
}
Would be something like this:
{
"type": "object",
"properties": {
"first": { "type": "string" },
"last": { "type": "string" },
}
}
You can then use the jsonschema
package for validation:
from jsonschema import validate
validate(
instance=json_to_validate, schema=json_schema,
)