1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
`clj-commons/clj-yaml` provides [YAML](http://yaml.org) encoding and
decoding for Clojure via the [snakeyaml][] Java library.
[SnakeYAML]: https://bitbucket.org/asomov/snakeyaml/
[](https://clojars.org/clj-commons/clj-yaml) [](https://cljdoc.org/d/clj-commons/clj-yaml/CURRENT)
[](https://circleci.com/gh/clj-commons/clj-yaml)
(This is a maintained fork of [the original][]).
[the original]: https://github.com/lancepantz/clj-yaml
## Usage
(require '[clj-yaml.core :as yaml])
(yaml/generate-string
[{:name "John Smith", :age 33}
{:name "Mary Smith", :age 27}])
"- {name: John Smith, age: 33}\n- {name: Mary Smith, age: 27}\n"
(yaml/parse-string "
- {name: John Smith, age: 33}
- name: Mary Smith
age: 27
")
=> ({:name "John Smith", :age 33}
{:name "Mary Smith", :age 27})
By default, keys are converted to clojure keywords. To prevent this,
add `:keywords false` parameters to the `parse-string` function:
(yaml/parse-string "
- {name: John Smith}
" :keywords false)
## Installation
`clj-commons/clj-yaml` is available as a Maven artifact from [Clojars](http://clojars.org/clj-commons/clj-yaml).
### Leiningen/Boot
```clojure
[clj-commons/clj-yaml "0.6.0"]
```
### Clojure CLI/`deps.edn`
```clojure
clj-commons/clj-yaml {:mvn/version "0.6.0"}
```
## Development
$ git clone git://github.com/clj-commons/clj-yaml.git
$ lein deps
$ lein test
$ lein install
|