[英]Send JSON data to compojure server from android
我正在嘗試將一些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();
測量是JSON對象。
以及用於處理路由的主要compojure代碼
(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
是否有人看到此代碼有問題或知道執行此操作的正確方法?
我相信params映射將字符串作為鍵,而不是關鍵字。
我建議使用ring-json-params 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.