Code: Select all
from jsonschema import validate
schema = {
"type": "object",
"properties": {
"key_1": {},
"key_2": {
"type": "string",
"default": "do_not_overwrite_if_key_exists",
},
"key_3": {
"type": "string",
"default": "use_it_if_key_does_not_exist",
},
},
"required": ["key_1"],
}
json_dict = {"key_1": "key_1_value", "key_2": "key_2_value"}
validate(json_dict, schema)
Ist das Standardwort des Standards < /code> wirklich so "nutzlos", wie die Dokumentation (siehe unten) sagt? Dies ist alles, was Sie bekommen? JSON_DICT in Folgendes gemäß dem Schlüsselwort Standard . Kennen Sie ein solches Paket?
Code: Select all
json_dict = {"key_1": "key_1_value", "key_2": "key_2_value", "key_3": "use_it_if_key_does_not_exist"}