Typed Namespaces ensure object typing is correct in the IDE!
import yaml
import json
from ns_utils import Loader, Dumper, object_hook, nsEncoder
# read from yaml
with open("./config.yaml") as fh:
data = yaml.load(fh, Loader=Loader)
# write to yaml
print(yaml.dump(data,Dumper = Dumper))
# write to json
js_data = json.dumps(data,cls=nsEncoder)
# read from json
json.loads(js_data,object_hook=object_hook)
* Tested with Python 3.7.3