如何通过JSONObject调用方法

时间:2015-07-10 09:40:36

标签: java spring jsonobject

我想通过JSONObject调用一些方法。这是我的代码

public JSONObject analyticsCustomer()  
{
    JSONObject ju = new JSONObject();
    ju.put("analyticsData",  analyticsCustomerlist());
}

以下是analyticsCustomerlist()方法:

private JSONArray analyticsCustomerlist()
{
    JSONArray analyticsCustomerArrayLast = new JSONArray();
    JSONObject jsonObject = new JSONObject();
    try{
        List<ReferralAnalyticsPOJO> analyticsCustomerlist = referralAnalyticsdao
                     .analyticsCustomer();

        JSONArray analyticsCustomerArray = new JSONArray();
        for (ReferralAnalyticsPOJO analytics : analyticsCustomerlist) {
            JSONObject jp = new JSONObject();

            jp.put("label", analytics.getDateDiff());
            jp.put("value", analytics.getCNT());
            analyticsCustomerArray.put(jp);
        }

        JSONObject jsonObject1 = new JSONObject();
        jsonObject1.put("key", "ana");
        jsonObject1.put("values", analyticsCustomerArray);
        analyticsCustomerArrayLast.put(jsonObject1);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return analyticsCustomerArrayLast;
}

我想通过analyticsCustomerlist()致电JSONObject ju。你能告诉我打电话的过程吗?因为它显示错误。

0 个答案:

没有答案