Skip to content

Commit 4cc7d27

Browse files
committed
Allow comments on json configs.
1 parent b05fd3c commit 4cc7d27

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Allow comments on `json` configs.
6+
57
## 0.0.4
68

79
- Add env support for MCPs

src/eca/config.clj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
4. `initializatonOptions` sent in `initialize` request."
88
(:require
99
[cheshire.core :as json]
10+
[cheshire.factory :as json.factory]
1011
[clojure.core.memoize :as memoize]
1112
[clojure.java.io :as io]
1213
[clojure.string :as string]
@@ -33,7 +34,9 @@
3334

3435
(defn ^:private safe-read-json-string [raw-string]
3536
(try
36-
(json/parse-string raw-string true)
37+
(binding [json.factory/*json-factory* (json.factory/make-json-factory
38+
{:allow-comments true})]
39+
(json/parse-string raw-string true))
3740
(catch Exception _
3841
nil)))
3942

@@ -48,7 +51,7 @@
4851
(io/file (get-property "user.home") ".config"))
4952
config-file (io/file xdg-config-home "eca" "config.json")]
5053
(when (.exists config-file)
51-
(safe-read-json-string (slurp config-file)))))
54+
(safe-read-json-string (slurp config-file)))))
5255

5356
(def ^:private config-from-global-file (memoize/ttl config-from-global-file* :ttl/threshold ttl-cache-config-ms))
5457

0 commit comments

Comments
 (0)