Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 4 days 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 4 years ago)
- Default Branch: main
- Last Pushed: 2024-03-02T18:56:32.000Z (12 months ago)
- Last Synced: 2025-01-31T13:43:40.564Z (14 days 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
![CI](https://github.com/GPrimola/yamel/workflows/Main%20CI/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/GPrimola/yamel/badge.svg?branch=master)](https://coveralls.io/github/GPrimola/yamel?branch=master)
[![Docs](https://img.shields.io/badge/api-docs-blueviolet.svg?style=flat)](https://hexdocs.pm/yamel)
![Hex.pm](https://img.shields.io/hexpm/v/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
```