https://github.com/gprimola/yamel
Yamel is a YAML parser and serializer lib for Elixir.
https://github.com/gprimola/yamel
elixir encoder-decoder hacktoberfest parser serializer yaml yaml-parser yml
Last synced: 8 months ago
JSON representation
Yamel is a YAML parser and serializer lib for Elixir.
- Host: GitHub
- URL: https://github.com/gprimola/yamel
- Owner: GPrimola
- Created: 2020-09-20T01:23:03.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-03-02T18:56:32.000Z (almost 2 years ago)
- Last Synced: 2025-06-14T09:05:09.610Z (8 months ago)
- Topics: elixir, encoder-decoder, hacktoberfest, parser, serializer, yaml, yaml-parser, yml
- Language: Elixir
- Homepage: https://hexdocs.pm/yamel/api-reference.html
- Size: 210 KB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Yamel - Yaml Serializer and Parser

[](https://coveralls.io/github/GPrimola/yamel?branch=master)
[](https://hexdocs.pm/yamel)

---
An [yaml](https://en.wikipedia.org/wiki/YAML) parser and serializer to work with Yaml files in Elixir.
## Installation
Add `yamel` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:yamel, "~> 2.0.4"}
]
end
```
## Usage
```elixir
yaml_string = ~S"""
foo: bar
zoo:
- caa
- boo
- vee
"""
Yamel.decode!(yaml_string) # equivalent to Yamel.decode!(yaml_string, keys: :string)
=> %{"foo" => "bar", "zoo" => ["caa", "boo", "vee"]}
Yamel.decode!(yaml_string, keys: :atom)
=> %{foo: "bar", zoo: ["caa", "boo", "vee"]}
Yamel.encode!(["caa", :boo, :"\"foo\""])
=> "- caa\n- boo\n- \"foo\"\n\n"
%{foo: :bar, zoo: :caa}
|> Yamel.encode!()
|> Yamel.IO.write!("/to/file.yml")
=> :ok
%{foo: value} = Yamel.IO.read!("/from/file.yaml")
```
### Deriving
```elixir
defmodule MyApp.MyStruct do
defstruct [:field1, :field2, :field3, field4: true]
@derive {Yamel.Encoder, only: [:field2, :field4]}
end
```