In the Wild

So far we have limited ourselves to the built-in libraries that come packaged with Java. But Clojure’s interop features work just as well with third-party libraries. For example, you might be interested in using Google’s take on reading and writing JSON, the Gson library.[29]

To get a feel for using Gson from Clojure, you might start by creating a new project:

 $ lein new exploregson
 
 Generating a project called `exploregson`...
 
 $ cd exploregson

Next we need to tell Leiningen that our project depends on a particular version of the Gson library. So we add the Gson library and its latest version (at least it’s the latest version as I write this) to the project.clj dependencies. The syntax is exactly the same for Java libraries ...

Get Getting Clojure now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.