File tree 1 file changed +29
-0
lines changed
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 5
5
A Clojure library designed to make working with JSON objects simpler and faster.
6
6
This wraps the ` jq ` native library that is provided by com.arakelian/java-jq.
7
7
8
+ ### Leiningen
9
+
10
+ ``` [me.bwest/clj-jq "1.0.0"] ```
11
+
12
+ ### Maven
13
+
14
+ ```
15
+ <dependency>
16
+ <groupId>me.bwest</groupId>
17
+ <artifactId>clj-jq</artifactId>
18
+ <version>1.0.0</version>
19
+ </dependency>
20
+ ```
21
+
22
+
8
23
## Usage
9
24
10
25
Very simply, 4 methods are provided
@@ -34,3 +49,17 @@ to do that. You could do that directly with the `jq` query string, though.
34
49
35
50
This also exposes ` jq/read ` which is just an alias of ` (clojure.data.json/read-str x :key-fn keyword) `
36
51
and ` jq/write ` , which just aliases ` clojure.data.json/write-str `
52
+
53
+ If you want to map an incoming JSON message to some consistently structured map, ` jq ` can do that:
54
+
55
+ ```
56
+ (jq/query json-str "{\"id\": .inbound.payload.messageId, \"url\": .inbound.payload.docUrl, \"date\": .metadata.originDate}")
57
+ ```
58
+
59
+ This will yield a map with the structure:
60
+
61
+ ```
62
+ {:id <id> :url <url> :date <date>}
63
+ ```
64
+
65
+ Values can then be mapped further into specialized data types using normal Clojure functions.
You can’t perform that action at this time.
0 commit comments