38 lines
597 B
Markdown
38 lines
597 B
Markdown
# YAML API
|
|
|
|
The YAML API provides functions for parsing and stringifying YAML content.
|
|
|
|
## YAML Operations
|
|
|
|
### yaml.parse(text)
|
|
Parses a YAML string into a Lua table.
|
|
|
|
Example:
|
|
```lua
|
|
local text = [[
|
|
name: John
|
|
age: 30
|
|
hobbies:
|
|
- reading
|
|
- hiking
|
|
]]
|
|
|
|
local data = yaml.parse(text)
|
|
print(data.name) -- prints: John
|
|
print(data.hobbies[1]) -- prints: reading
|
|
```
|
|
|
|
### yaml.stringify(obj)
|
|
Converts a Lua table into a YAML string.
|
|
|
|
Example:
|
|
```lua
|
|
local data = {
|
|
name = "John",
|
|
age = 30,
|
|
hobbies = {"reading", "hiking"}
|
|
}
|
|
|
|
local yaml_text = yaml.stringify(data)
|
|
print(yaml_text)
|
|
``` |