lancepantz / clj-yaml Goto Github PK
View Code? Open in Web Editor NEWYAML encoding and decoding for Clojure via SnakeYAML
License: Other
YAML encoding and decoding for Clojure via SnakeYAML
License: Other
If replacing the current behavior is acceptable, then the change is
java.util.ArrayList
(decode [data]
(mapv decode data))
If replacing current behavior isn't acceptable, then provide a way to optionally select this behavior...
There's no statement of license in the source tree or documentation. The default license in most countries does not allow for free use.
Reflection warning, clj_yaml/core.clj:19 - call to dump can't be resolved.
Reflection warning, clj_yaml/core.clj:34 - call to load can't be resolved.
"Dump" and "Load" are idiomatic methods within YAML (including SnakeYAML), see:
It looks like this library isn't actively maintained anymore. I'd suggest looking at https://github.com/owainlewis/yaml as an alternative.
being able to do (yaml/parse-string "\uFFFD � ")
without yaml parsing exploding would be nice
;; works:
(def typed-data-yaml "
the-bin: !!binary 0101")
(clj-yaml.core/parse-string typed-data-yaml)
;= {:the-bin #<byte[] [B@61911e64>}
(clj-yaml.core/generate-string
(clj-yaml.core/parse-string typed-data-yaml)
:dumper-options {:flow-style :block})
;= "the-bin: !!binary |-\n 0101\n"
;; generate-string creates a sequence instead of a set:
(def set-yaml "
--- !!set
? Mark McGwire
? Sammy Sosa
? Ken Griff")
(clj-yaml.core/parse-string set-yaml)
;= #{"Mark McGwire" "Ken Griff" "Sammy Sosa"}
(clj-yaml.core/generate-string
(clj-yaml.core/parse-string set-yaml)
:dumper-options {:flow-style :block})
;= "- Mark McGwire\n- Ken Griff\n- Sammy Sosa\n"
(clj-yaml.core/parse-string
(clj-yaml.core/generate-string
(clj-yaml.core/parse-string set-yaml)
:dumper-options {:flow-style :block}))
;= ("Mark McGwire" "Ken Griff" "Sammy Sosa")
(yaml/generate-string {46 "MAYBE" 52 "DEFINITELY"})
"{46: MAYBE, 52: DEFINITELY}\n"
(yaml/parse-string (yaml/generate-string {46 "MAYBE" 52 "DEFINITELY"}))
{nil "DEFINITELY"}
This seems to be legal YAML, and SnakeYAML itself seems to handle it AFAICT.
(clj-yaml.core/generate-string {:x :y :a "b"} :dumper-options {:flow-style :flow})
;= "{x: y, a: b}\n"
(clj-yaml.core/generate-string {:x :y :a "b"} :dumper-options {:flow-style :block})
;= "x: y\na: b\n"
(clj-yaml.core/generate-string {:x :y :a 'b} :dumper-options {:flow-style :flow})
;= "{x: y, a: !!clojure.lang.Symbol {}}\n"
(clj-yaml.core/generate-string {:x :y :a 'b} :dumper-options {:flow-style :block})
;= "x: y\na: !!clojure.lang.Symbol {}\n"
Perhaps something like {:native-keywords true :native-symbols true :native-vectors false}
=> (println (yaml-dump ['a/b/c :d/e/f (symbol "stuff and/or things") (keyword "other and/or widgets")]))
---
- !!clojure.lang.Symbol
name: c
namespace: a/b
- !!clojure.lang.Keyword
name: f
namespace: d/e
sym:
name: f
namespace: d/e
- !!clojure.lang.Symbol
name: or things
namespace: stuff and
- !!clojure.lang.Keyword
name: or widgets
namespace: other and
sym:
name: or widgets
namespace: other and
...
clojure.lang.Keyword
(encode [data]
(.substring (str data) 1))
clojure.lang.Symbol
(encode [data]
(str data))
=> (println (yaml-dump ['a/b/c :d/e/f (symbol "stuff and/or things") (keyword "other and/or widgets")]))
---
- a/b/c
- d/e/f
- stuff and/or things
- other and/or widgets
...
(Encoding style similar to cheshire: https://github.com/dakrone/cheshire/blob/6d78a56929f3cb4e925e2d09617465314d3114ba/src/cheshire/generate.clj#L134 )
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.