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 libertypi
def yaml(a):
# your code here
obj = {}
for l in a.splitlines():
l = l.split(':', 1)
if len(l) == 2:
k, v = l[0], l[1].strip().replace('\\', '')
if v.isdigit():
v = int(v)
elif v == 'true':
v = True
elif v == 'false':
v = False
elif v == 'null' or v == '':
v = None
elif v and (v[0] == "'" or v[0] == '"'):
v = v[1:-1]
obj[k] = v
return obj
June 14, 2020
Comments: