我正在尝试将一些 json 数据从 Android 发送到 clojure/compojure 服务器
但是,我似乎无法正确发送或接收数据,而且我不太确定问题出在 Android 还是 compojure 上。
这是java代码
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();
其中 mesurements 是 JSON 对象。
以及处理路由的主要组合代码
(defroutes main-routes
(POST "/get_position" {params :params}
(emit-json (find-location (:results (read-json (:measurements params))))))
(route/not-found "Page not found"))
请求已正确收到,但我收到一个错误,即 params 为 nil
java.lang.IllegalArgumentException: No implementation of method: :read-json-from of protocol: #'clojure.data.json/Read-JSON-From found for class: nil
是否有人看到此代码有问题或知道正确的方法?