[#147] Add cheshire

This commit is contained in:
Michiel Borkent 2019-12-10 09:44:41 +01:00 committed by GitHub
parent 09e16cc8a4
commit 3c5581fa34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 5 deletions

View file

@ -151,8 +151,9 @@ Everything after that is bound to *command-line-args*.
The `clojure.core` functions are accessible without a namespace alias.
The following namespaces are required by default and available through the
pre-defined aliases. You may use `require` + `:as` and/or `:refer` on these
namespaces. If not all vars are available, they are enumerated explicitly.
pre-defined aliases in the `user` namespace. You may use `require` + `:as`
and/or `:refer` on these namespaces. If not all vars are available, they are
enumerated explicitly.
- `clojure.string` aliased as `str`
- `clojure.set` aliased as `set`
@ -169,6 +170,7 @@ namespaces. If not all vars are available, they are enumerated explicitly.
aliased as `conch`
- [`clojure.tools.cli`](https://github.com/clojure/tools.cli) aliased as `tools.cli`
- [`clojure.data.csv`](https://github.com/clojure/data.csv) aliased as `csv`
- [`cheshire.core`](https://github.com/dakrone/cheshire) aliased as `json`
The following Java classes are available:

View file

@ -14,7 +14,8 @@
[borkdude/edamame "0.0.9-alpha.2"]
[org.clojure/core.async "0.4.500"]
[org.clojure/tools.cli "0.4.2"]
[org.clojure/data.csv "0.1.4"]]
[org.clojure/data.csv "0.1.4"]
[cheshire "5.9.0"]]
:profiles {:test {:dependencies [[clj-commons/conch "0.9.2"]]}
:uberjar {:global-vars {*assert* false}
:jvm-opts ["-Dclojure.compiler.direct-linking=true"

View file

@ -0,0 +1,14 @@
(ns babashka.impl.cheshire
{:no-doc true}
(:require [cheshire.core :as json]))
(def cheshire-core-namespace
{'encode json/encode
'generate-string json/generate-string
'encode-stream json/encode-stream
'generate-stream json/generate-stream
'encode-smile json/encode-smile
'generate-smile json/generate-smile
'decode json/decode
'parse-string json/parse-string
'decode-smile json/decode-smile})

View file

@ -2,6 +2,7 @@
{:no-doc true}
(:require
[babashka.impl.async :refer [async-namespace]]
[babashka.impl.cheshire :refer [cheshire-core-namespace]]
[babashka.impl.clojure.core :refer [core-extras]]
[babashka.impl.clojure.java.io :refer [io-namespace]]
[babashka.impl.clojure.stacktrace :refer [print-stack-trace]]
@ -215,7 +216,8 @@ Everything after that is bound to *command-line-args*."))
io clojure.java.io
conch me.raynes.conch.low-level
async clojure.core.async
csv clojure.data.csv}
csv clojure.data.csv
json cheshire.core}
:namespaces {'clojure.core (assoc core-extras
'*command-line-args* command-line-args)
'clojure.tools.cli tools-cli-namespace
@ -227,7 +229,8 @@ Everything after that is bound to *command-line-args*."))
'clojure.java.io io-namespace
'me.raynes.conch.low-level conch-namespace
'clojure.core.async async-namespace
'clojure.data.csv csv/csv-namespace}
'clojure.data.csv csv/csv-namespace
'cheshire.core cheshire-core-namespace}
:bindings {'java.lang.System/exit exit ;; override exit, so we have more control
'System/exit exit}
:env env