2
votes

I'm trying to send some json data from Android to a clojure/compojure server

However I can't seem to able to properly send or receive the data, and I'm not quite sure if the problem lies with Android or compojure.

Here is the java code

String PATH = "http://localhost:8080/get_position";
DefaultHttpClient mClient = new DefaultHttpClient();

HttpGet httpget = new HttpGet(PATH);
HttpResponse response;
httpget.getParams().setParameter("measurements", measurements.toString());

response = mClient.execute(httpget);
HttpEntity entity = response.getEntity();

Where mesurements is the JSON object.

And the main compojure code for handling the routing

(defroutes main-routes
   (POST "/get_position" {params :params}
      (emit-json (find-location (:results (read-json (:measurements params))))))
   (route/not-found "Page not found"))

The request is properly received, but I get an error that params is nil

java.lang.IllegalArgumentException: No implementation of method: :read-json-from of protocol: #'clojure.data.json/Read-JSON-From found for class: nil   

Does anyone see a problem with this code or knows the correct way to do this?

2

2 Answers

0
votes

The params map has strings as keys, I believe, not keywords.

0
votes