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 igor.v.dudenko
def convert_value(val):
if not val or val == 'null':
return None
if val.isnumeric():
return int(val)
bool_value = {'false': False, 'true': True}
if val in bool_value:
return bool_value[val]
val = val.replace('\\','')
if val[0] in '\'"':
return val[1:-1]
else:
return val
def yaml(a):
lines = [line.split(':') for line in a.splitlines() if line]
return {
key: convert_value(value.strip())
for key, value in lines
}
Dec. 13, 2019