使用Atom+Leiningen开发Clojure:JSON解析依赖添加报错求助
clojure.data.json Dependency Issue in Your Leiningen/Clojure Project Hey there! Let's get that JSON parsing working for your university project. The error you're seeing happens because Leiningen doesn't know about the clojure.data.json library yet—we need to add it to your project's dependencies first. Here's how to do it step by step:
Locate your
project.cljfile
This file lives in the root folder of your Clojure project (the same place where you runleincommands from). If you started your project withlein new, it should be right there waiting for you.Add the
clojure.data.jsondependency
Openproject.cljin Atom, and look for the:dependenciesvector. It’ll already have an entry for Clojure itself—add thedata.jsondependency inside that vector. Here’s an example of what it should look like:(defproject your-project-name "0.1.0-SNAPSHOT" ;; ... other project settings like description or license ... :dependencies [[org.clojure/clojure "1.11.1"] ;; Add this line below the Clojure dependency [org.clojure/data.json "2.4.0"]] ;; ... rest of your project config ... )The version
2.4.0is a stable, recent release that works perfectly for basic JSON parsing tasks.Let Leiningen fetch the dependency
Save theproject.cljfile. If you have a REPL running in Atom already, close it first. Then either:- Open a terminal in your project root and run
lein deps(this explicitly tells Leiningen to download the new library), or - Start a new REPL directly in Atom—Leiningen will automatically grab the dependency when it boots up.
- Open a terminal in your project root and run
Test your require statement again
Once the REPL is running, try your original code again:(ns example (:require [clojure.data.json :as json]))The
FileNotFoundExceptionshould be gone, and you can start working with JSON!
Quick Heads-Up
Remember: Atom is just your code editor—all dependency management for Clojure projects is handled by Leiningen via the project.clj file. No matter which editor you use, this is the standard way to add new libraries to your project.
内容的提问来源于stack exchange,提问作者broliverparker

