https://github.com/pbalduino/dandelion
A Clojure wrapper for Amazon Ion
https://github.com/pbalduino/dandelion
amazon clojure dandelion ion ion-data
Last synced: 2 months ago
JSON representation
A Clojure wrapper for Amazon Ion
- Host: GitHub
- URL: https://github.com/pbalduino/dandelion
- Owner: pbalduino
- License: mit
- Created: 2019-09-18T07:50:27.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-28T14:21:55.000Z (over 5 years ago)
- Last Synced: 2025-03-27T06:18:31.529Z (3 months ago)
- Topics: amazon, clojure, dandelion, ion, ion-data
- Language: Clojure
- Size: 17.6 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dandelion
[](https://clojars.org/pbalduino/dandelion)
[](https://cljdoc.org/d/pbalduino/dandelion/CURRENT)
## What?
`Dandelion` is a small and lightweight library that allows you to convert Clojure data to Ion data and vice-versa without the burden to dive third-party source code or rely on outdated and half-baked documentation.
## Why?
From [Ion Docs](http://amzn.github.io/ion-docs/guides/why.html):
> Ion provides dual-format interoperability, which enables users to take advantage of the ease of use of the text format while capitalizing on the efficiency of the binary format. The text form is easy to prototype, test, and debug, while the binary format saves space and parsing effort.
>
> Ion’s rich type system extends JSON’s, adding support for types that make Ion suitable for a wider variety of uses, including precision-sensitive applications and portability across languages and runtimes.
>
> Ion is a self-describing format, giving its readers and writers the flexibility to exchange Ion data without needing to agree on a schema in advance. Ion’s “open-content” supports discovery, deep component chaining, and schema evolution.
>
> Because most data is read more often than it is written, Ion defines a read-optimised binary format.And because you're now writing something in Clojure (yeah!) and need to interoperate with this awkward format (boo!).
## How?
### Lein/Boot
```
[pbalduino/dandelion "0.1.1"]
```### deps.edn
```
pbalduino/dandelion {:mvn/version "0.1.1"}
```### Samples
```clojure
(require [dandelion.core :refer [clj->ion ion->clj])(def sample-data {"text" "some text"
"number" 1234
"array" [1, 2, 3, 4]
"obj" {"more-array" [5, 6, 7]
"more-number" 789.3}
"bool" true
"null" nil});; To transform Clojure data in Ion value
(-> sample-data ; some Clojure data
clj->ion ; where the magic happens
str ; convert to a readable string
println) ; show me the money; {text:"some text",number:1234,array:[1,2,3,4], ↵
; obj:{'more-array':[5,6,7],'more-number':789.3}, ↵
; bool:true,'null':null};; To transform Ion value to Clojure data
(def ion-value (clj->ion sample-data))(-> ion-value ; Ion value
ion->clj ; simple, uh?
clojure.pprint/pprint) ; welcome back; {"text" "some text",
; "number" 1234,
; "array" [1 2 3 4],
; "obj" {"more-array" [5 6 7], "more-number" 789.3},
; "bool" true,
; "null" nil}
```That's all.
## Who?
[Plínio Balduino](https://github.com/pbalduino), software developer and problem solver.### Contributors (Thank you!)
* Shayan Fouladi