Skip to content

Commit 712ebb6

Browse files
authored
Merge pull request #31 from simonneutert/json-ld
[Documentation] Adds json-ld to documentation
2 parents 51f00f6 + 5109349 commit 712ebb6

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ classes/
55
target/
66
.clj-kondo/
77
pom.xml
8+
.calva

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ cq aims to:
4747
- Data Formats:
4848
- EDN
4949
- YAML
50-
- JSON
50+
- JSON (regular + [line-delimited](https://jsonlines.org/))
5151
- XML
5252
- MsgPack
5353
- CSV
@@ -81,8 +81,8 @@ Examples
8181
printf 'http://example.com/some/path' | cq -i text -- '-> str/upper-case (str/split #"/") ->> (map str/reverse)'
8282
8383
Options:
84-
-i, --in FORMAT yaml Input format: csv, edn, json, lines, msgpack, text, transit, yaml, html
85-
-o, --out FORMAT edn Output format: csv, edn, json, lines, msgpack, text, transit, yaml, html
84+
-i, --in FORMAT yaml Input format: csv, edn, json, json-ld, lines, msgpack, text, transit, yaml, html
85+
-o, --out FORMAT edn Output format: csv, edn, json, json-ld, lines, msgpack, text, transit, yaml, html
8686
-p, --[no-]pretty Pretty print output - default is true
8787
--color COLOR auto When pretty printing, whether to use colors: auto, off, on - default is auto
8888
-c Same as --color=on

test/cq/formats_test.clj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@
5656
(testing "pretty"
5757
(is (= "{\"a\":{\"b\":[1, 2, 3]}}\n" (test-writer-str sut/->json-writer {:pretty true} {:a {:b [1 2 3]}}))))))
5858

59+
(deftest json-ld
60+
(testing "reader"
61+
(is (= '({:a {:b [1 2 3]}}) (test-reader-str sut/->json-ld-reader nil "{\"a\": {\"b\": [1, 2, 3]}}"))))
62+
63+
(testing "writer"
64+
(is (= "{\"a\":{\"b\":[1,2,3]}}\n" (test-writer-str sut/->json-ld-writer nil {:a {:b [1 2 3]}})))
65+
66+
(testing "pretty"
67+
(is (= "{\"a\":{\"b\":[1,2,3]}}\n" (test-writer-str sut/->json-ld-writer {:pretty true} {:a {:b [1 2 3]}}))))))
68+
5969
(deftest edn
6070
(testing "reader"
6171
(is (= {:a {:b [1 2 3]}} (test-reader-str sut/->edn-reader nil "{:a {:b [1 2 3]}}"))))

0 commit comments

Comments
 (0)