把ArrayList转化为Json格式,在用url编码

    xiaoxiao2026-06-18  3

    先把ArrayList转化为Json格式 JSONArray json = new JSONArray(); for (int i = 0; i < cartinfo.size(); i++) { JSONObject jo = new JSONObject(); try { jo.put("shopid", cartinfo.get(i).getShopid()); jo.put("gounum", cartinfo.get(i).getGounum()); json.put(jo); } catch (JSONException e) { e.printStackTrace(); } }

    把json转成url编码

    String encode = URLEncoder.encode(json.toString()); payCode.setCartinfo(encode);

    转载请注明原文地址: https://ju.6miu.com/read-1310664.html
    最新回复(0)