On 16 March 2010 22:26, frye <twash...@gmail.com> wrote:
> I'm getting an error, trying to use the JSON API in the clojure-
> contrib library:
>
> user=> (ns foo
>  (:require clojure.contrib.json))
> java.lang.Exception: Unable to resolve symbol: defprotocol in this
> context (json.clj:167)

defprotocol is a Clojure version 1.2 thing.  i.e. it does not exist in
any released version of Clojure yet.  It looks like you're trying to
use a version of clojure.contrib that is too new for your version of
clojure.  I've not used clojure.contrib.json, but the version in
clojure-contrib 1.1.0 should work with clojure 1.1.0.

> I tried clojure-contrib 1.1.0 with clojure 1.0.0 and 1.1.0. As of
> today (March 16th, 2010), I tried getting the latest clojure code and
> clojure-contrib code from 1) SVN and 2) GIT respectively.
>
> 1) svn checkout http://clojure.googlecode.com/svn/trunk/ clojure-read-
> only

The Subversion repositories (on Sourceforge and Google code) were
abandoned long ago.  Don't use them.

> 2) git://github.com/richhickey/clojure-contrib.git
>
> I'm still getting the error. What library setup do I need to run this
> library contrib successfully? Thanks in advance.

$ git clone ...clojure.git
$ cd clojure
$ git checkout -b v1.1.0 1.1.0
Switched to a new branch 'v1.1.0'
$ ant
[...]
BUILD SUCCESSFUL
Total time: 15 seconds
$ cp clojure-1.1.0.jar /tmp
$ cd ..
$ git clone ...clojure-contrib.git
$ cd clojure-contrib
$ git checkout -b v1.1.0 1.1.0
Switched to a new branch 'v1.1.0'
$ ant
[...]
BUILD SUCCESSFUL
Total time: 18 seconds
$ cp clojure-contrib.jar /tmp
$ cd /tmp
$ java -cp clojure-1.1.0.jar:clojure-contrib.jar clojure.main
Clojure 1.1.0
user=> (ns foo
 (:require clojure.contrib.json))
java.io.FileNotFoundException: Could not locate
clojure/contrib/json__init.class or clojure/contrib/json.clj on
classpath:  (NO_SOURCE_FILE:1)

So it seems the API has changed.  If you look here you will find the 1.1.x API:

http://richhickey.github.com/clojure-contrib/branch-1.1.x/json.read-api.html

$ java -cp clojure-1.1.0.jar:clojure-contrib.jar clojure.mainClojure 1.1.0
user=> (ns foo (:require clojure.contrib.json.read))
nil
foo=>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to