parse-string
function
clj-yaml.core/parse-string
(parse-string [yaml-string & opts])Returns parsed `yaml-string` as Clojure data structures.
Valid `& opts` (`opts` are keyword args, see [docs](/doc/01-user-guide.adoc#keyword-args)):
- `:key-fn` - Single-argument fn, arg is a map with `:key`; called on YAML keys, return replaces YAML key.
- default behaviour: see `:keywords`
- overrides `:keywords`, consider using this option instead of `:keywords`
- see [docs](/doc/01-user-guide.adoc#key-conv)
- `:keywords` - when `true` attempts to convert YAML keys to Clojure keywords, else makes no conversion
- default: `true`.
- ignored when `:key-fn` is specified
- when clj-yaml detects that a YAML key cannot be converted to a legal Clojure keyword it leaves the key as is.
- detection is not sophisticated and clj-yaml will produce invalid Clojure keywords, so although our default is `true` here, `false` can be a better choice.
- consider instead using `:key-fn`
- see [docs](/doc/01-user-guide.adoc#key-conv)
- `:load-all` - when `true` loads all YAML documents from `yaml-string` and returns a vector of parsed docs.
Else only first YAML document is loaded, and return is that individual parsed doc.
- default: `false`
- `:unknown-tag-fn` - Single-argument fn, arg is map with keys `:tag` and `:value`; return replaces the YAML tag and value.
- default behaviour: clj-yaml throws on unknown tags.
- see [docs](/doc/01-user-guide.adoc#unknown-tags) for example usage.
- `:max-aliases-for-collections` the maximum number of YAML aliases for collections (sequences and mappings).
- Default: `50`
- throws when value is exceeded.
- `:nesting-depth-limit` the maximum number of nested YAML levels.
- Default: `50`
- throws when value is exceeded.
- `:code-point-limit` the maximum number of code points (document size).
- Default: `3145728`
- throws when value is exceeded.
- `:allow-recursive-keys` - when `true` allows recursive keys for mappings. Only checks the case where the key is the direct value.
- Default: `false`
- `:allow-duplicate-keys` - when `false` throws on duplicate keys.
- Default: `true` - last duplicate key wins.
- `:unsafe` - when `true` attempt to load tagged elements to Java objects, else prohibits via throw.
- default: `false`
- **WARNING**: be very wary of parsing unsafe YAML. See [docs](/doc/01-user-guide.adoc#unsafe)
- `:mark` - when `true` position of YAML input is tracked and returned in alternate structure.
- default: `false`
- see [docs](/doc/01-user-guide.adoc#mark)
Note: clj-yaml will only recognize the first of `:unsafe`, `:mark` or `:unknown-tag-fn`
Examples
No examples yet. Be the first to add one!