0

I am trying to use the JSON library on clojure, but I am not able to install it, and I instead get the

[org.clojure/data.json "2.4.0"]
Syntax error (ClassNotFoundException) compiling at (REPL:0:0).
org.clojure

error message, I am using IntelliJ IDEA and I created a Deps project with this structure, in the deps.edn file I have:

{:paths ["src"]
 :deps  {org.clojure/spec.alpha {:mvn/version "0.3.218"}}}
 {:deps {org.clojure/test.check {:mvn/version "1.1.0"}}}
 {:deps {org.clojure/data.json {:mvn/version "2.4.0"}}}

But when I evaluate the {:deps {org.clojure/data.json {:mvn/version "2.4.0"}}} line in the terminal, I get the error message that I previously showed.

I dont have any plugin or whatever, I write the code on the IDE and then I run the clojure command on the terminal and evaluate the code I just wrote. Maybe that is the cause of the issue?

I found this, this and this sites but somehow they don't work for me. Thanks if you can help.

1 Answers1

1

The deps.edn file is a map, and in a map, you can have any number of distinct keys. A deps.edn file has a structure as follows:

    {:paths ["path1" "path2" ..]
     :deps { deps1
             deps2
             ... }
     :aliases {
       :alias1 {}
       :alise2 {}
       ...
     }
    }

And in your case, it will be as follows:

 {:paths ["src"]
  :deps  {org.clojure/spec.alpha {:mvn/version "0.3.218"}
          org.clojure/test.check {:mvn/version "1.1.0"}
          org.clojure/data.json {:mvn/version "2.4.0"}}}
Maziyar Grami
  • 305
  • 1
  • 2
  • 10
  • I just pasted the 2nd code but I get `Syntax error (ClassNotFoundException) compiling at (REPL:0:0). org.clojure #:mvn{:version "2.4.0"} ` error. Basically I am in the same problem as I can't include the library. – SomeoneThatCodes Jan 14 '23 at 19:57
  • 2
    It appears that you are trying to eval the above in the REPL? You are supposed to edit the `deps.edn` file as shown above and then restart your REPL. That will load the needed dependencies. – Thomas Heller Jan 18 '23 at 09:42