edn-rs 0.3.4

Crate to parse and emit EDN
Documentation

edn-rs

[Experimental] Crate to parse and emit EDN

  • This lib does not make effort to conform the EDN received to EDN Spec.

Usage

Cargo.toml

[dependencies]
edn-rs = "0.2.1"

Parse an EDN into a EdnNode:

extern crate edn_rs;

use edn_rs::parse_edn;

fn main() {
    ...
    let edn = String::from("[1 2 [:3 \"4\"]]");
    let value = parse_edn(edn);
    ...
}

Emits EDN format from a Json file

use edn_rs::emit_edn;

fn main() {
    let json = String::from("{\"hello\": \"world\"}");
    let edn = String::from("{:hello \"world\"}");

    assert_eq!(edn, emit_edn(json));
}

Current Features

  • Define struct to map EDN info EdnNode
  • Define EDN types, EdnType
  • Parse simples EDN data:
    • nil ""
    • String "\"string\""
    • Numbers "324352", "3442.234", "3/4"
    • Keywords :a
    • Vector "[1 :2 \"d\"]"
    • List "(1 :2 \"d\")"
    • Set "#{1 2 3}"
    • Map "{:a 1 :b 2 }"
  • Simple data structures in one another:
    • Vec in Vec "[1 2 [:3 \"4\"]]"
    • Set in Vec "[1 2 #{:3 \"4\"}]"
    • List in List "(1 2 (:3 \"4\"))"
    • Set in List "'(1 2 #{:3 \"4\"})"
    • Set in Set (Sets will not be sorted and don't need a dedup due to the fact that they need to be compliant with EDN spec)
    • Maps in general "{:a 2 :b {:3 \"4\"}}", "{:a 2 :b [:3 \"4\"]}"
  • Multiple simple data structures in one another (Map and Set in a vector)
  • Multi deepen data structures (Map in a Set in a List in a Vec in a Vec)
  • Json to Edn
    • Json String to EDN String
    • macro to process Structs and Enums to EDN
  • Edn to Json