我正在尝试将一些 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 is nil
java.lang.IllegalArgumentException: No implementation of method: :read-json-from of protocol: #'clojure.data.json/Read-JSON-From found for class: nil
有没有人发现此代码有问题或知道执行此操作的正确方法?
最佳答案
params 映射以字符串作为键,我相信,而不是关键字。
关于android - 将 JSON 数据从 android 发送到 compojure 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8555701/