Forum Archive

PyYAML package in Pythonista

atonaltensor

I'm trying to write a basic script that converts YAML to JSON.

By searching this forum, it seems like Editorial has the YAML package built-in, but NOT in Pythonista. Is that correct?'

I've tried importing YAML and also trying a my_dict = yaml.load() command in Pythonista, but they are not recognized.

Finally, is it possible to concert YAML to JSON if I were to buy Editorial?

Warm regards.

cvp

@atonaltensor try in lowercase

import yaml 

and an example here

or

import yaml
document = """
  a: 1
  b:
    c: 3
    d: 4
"""
print(yaml.dump(yaml.load(document)))
atonaltensor

Thank you.

I can't actually be sure why it wasn't working on my first try, but it is now. Thanks.

ccc
>>> import yaml
>>> yaml.__version__
'3.11'