Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for YAML. More Types by very.lazy.ghost
def yaml(a):
d = {}
arr = a.split('\n')
for i in range(len(arr)):
if len(arr[i].split()) != 0:
buf = arr[i].split(': ')
print(buf)
if buf[0].find(':') == len(buf[0]) - 1:
d[buf[0][:-1]] = None
elif buf[1].isdigit():
d[buf[0]] = int(buf[1])
elif buf[1].lower() == "false":
d[buf[0]] = False
elif buf[1].lower() == "true":
d[buf[0]] = True
elif buf[1] == 'null':
d[buf[0]] = None
else:
d[buf[0]] = buf[1].replace('\\"', '%1').replace('"', '').replace('%1', '"').strip()
return d
Aug. 6, 2020