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 ssk8
def yaml(a):
yaml_dict = dict()
entries = [entry for entry in sorted(a.splitlines()) if entry]
for entry in entries:
k, v = entry.split(":")
v = v.strip()
if v.isnumeric():
v = int(v)
if v == 'false':
v = False
if v in ('', 'null'):
v = None
if type(v) == str:
if v[0] == v[~0] and v[0] in ('"', "'"):
v = v[1:~0]
v = v.replace('\\', '')
yaml_dict[k] = v
return yaml_dict
Jan. 15, 2020
Comments: