Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for YAML. More Types by l.szyman10
# Taken from mission YAML. Simple Dict
def yaml(data):
data = dict([pos.split(':') for pos in data.splitlines() if pos])
for key in data.keys():
data[key] = data[key].strip()
if data[key].startswith('"') and data[key].endswith('"'):
if data[key] == '"null"':
data[key] = 'null'
continue
else:
data[key] = data[key][1:-1]
data[key] = data[key].replace('\\','')
if data[key].isdigit(): data[key]=int(data[key])
elif data[key] in ('true', 'false'): data[key] = eval(data[key].title())
elif data[key] == 'null' or not data[key]: data[key] = None
return data
Oct. 13, 2020