# yaml

> Parse and serialize YAML, and convert between YAML and JSON.

# yaml

The `yaml` module parses YAML into navigable values, converts YAML to and from JSON, and reads top-level keys. Import it with `import yaml`.

## Functions

| Function | Signature | Description |
| --- | --- | --- |
| `valid` | `yaml.valid(s: string) → bool` | Whether `s` is valid YAML |
| `parse` | `yaml.parse(s: string) → any` | Parse into a navigable object/array/scalar tree |
| `parseString` | `yaml.parseString(s: string) → string` | Parse YAML and re-emit as a JSON string |
| `stringify` | `yaml.stringify(j: string) → string` | Convert a JSON string to YAML |
| `get` | `yaml.get(s: string, key: string) → string` | Top-level key value as a string |

## Example

```goost
import yaml

let cfg = "name: alice\nage: 30\n"
let doc = yaml.parse(cfg)
print(doc.name)                         // alice

let asJson = yaml.parseString(cfg)
let backToYaml = yaml.stringify(asJson)
print(backToYaml)
```