Skip to content

Commit ed6f87e

Browse files
author
Brian West
committedMar 18, 2019
doc(readme): added more usage
1 parent 5ce2da0 commit ed6f87e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
 

‎README.md

+29
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@
55
A Clojure library designed to make working with JSON objects simpler and faster.
66
This wraps the `jq` native library that is provided by com.arakelian/java-jq.
77

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+
823
## Usage
924

1025
Very simply, 4 methods are provided
@@ -34,3 +49,17 @@ to do that. You could do that directly with the `jq` query string, though.
3449

3550
This also exposes `jq/read` which is just an alias of `(clojure.data.json/read-str x :key-fn keyword)`
3651
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.

0 commit comments

Comments
 (0)
Please sign in to comment.