[Experimental] Crate to parse and emit EDN * This lib does not make effort to conform the EDN received to EDN Spec. The lib that generated this EDN should be responsible for this.
Cargo.toml
toml
[dependencies]
edn-rs = "0.4.1"
Parse an EDN into a EdnNode
:
```rust
extern crate edn_rs;
fn main() { let edn = edn!((1 1.2 3 false :f nil 3/4)); let expected = Edn::List( List::new( vec![ Edn::Int(1), Edn::Double(1.2), Edn::Int(3), Edn::Bool(false), Edn::Key("f".tostring()), Edn::Nil, Edn::Rational("3/4".tostring()) ] ) );
assert_eq!(edn, expected);
} ```
Emits EDN format from a Json file ```rust use ednrs::emitedn;
fn main() { let json = String::from("{\"hello\": \"world\"}"); let edn = String::from("{:hello \"world\"}");
assert_eq!(edn, emit_edn(json));
} ```
struct
to map EDN info EdnNode
EdnType
""
"\"string\""
"324352"
, "3442.234"
, "3/4"
:a
"[1 :2 \"d\"]"
"(1 :2 \"d\")"
"#{1 2 3}"
For now the usage of Set is defined as a Vec<Edn>
, this is due to the fact that the lib should not be necessarily responsible for assuring the Set's unicity. A solution could be changing the implementation to HashSet
."{:a 1 :b 2 }"
"[1 2 [:3 \"4\"]]"
"[1 2 #{:3 \"4\"}]"
"(1 2 (:3 \"4\"))"
"'#{1 2 (:3 \"4\")}"
"{:a 2 :b {:3 \"4\"}}"
, "{:a 2 :b [:3 \"4\"]}"