You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Atom+Leiningen开发Clojure:JSON解析依赖添加报错求助

Fixing the 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:

  1. Locate your project.clj file
    This file lives in the root folder of your Clojure project (the same place where you run lein commands from). If you started your project with lein new, it should be right there waiting for you.

  2. Add the clojure.data.json dependency
    Open project.clj in Atom, and look for the :dependencies vector. It’ll already have an entry for Clojure itself—add the data.json dependency 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.0 is a stable, recent release that works perfectly for basic JSON parsing tasks.

  3. Let Leiningen fetch the dependency
    Save the project.clj file. 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.
  4. Test your require statement again
    Once the REPL is running, try your original code again:

    (ns example (:require [clojure.data.json :as json]))
    

    The FileNotFoundException should 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 06:51:23