Example usage for org.json JSONArray getJSONArray

List of usage examples for org.json JSONArray getJSONArray

Introduction

In this page you can find the example usage for org.json JSONArray getJSONArray.

Prototype

public JSONArray getJSONArray(int index) throws JSONException 

Source Link

Document

Get the JSONArray associated with an index.

Usage

From source file:src.Parser.java

public static void main(String[] args) throws JSONException {
    HttpQuery http = new HttpQuery();
    String response = "";
    try {//from   w w w .  ja v  a 2  s . c om
        response = http.send(
                "http://router.project-osrm.org/viaroute?loc=50.4423,30.5298&loc=50.4433,30.5151&z=0&instructions=true&geometry=false");
    } catch (Exception ex) {
        Logger.getLogger(Parser.class.getName()).log(Level.SEVERE, null, ex);
    }
    JSONObject obj = new JSONObject(response);
    JSONArray arr = obj.getJSONArray("route_instructions");
    JSONArray arr2;
    for (int i = 0; i < arr.length(); i++) {
        arr2 = arr.getJSONArray(i);
        String str = arr2.getString(0) + ", " + arr2.getString(1) + ", " + arr2.getInt(2) + ", "
                + arr2.getInt(3) + ", " + arr2.getInt(4);
        System.out.println(str);

        System.out.println();
    }
    System.out.println();
    System.out.println(response);
}

From source file:com.liferay.mobile.android.v7.socialactivity.SocialActivityService.java

public JSONArray getActivities(long classNameId, int start, int end) throws Exception {
    JSONObject _command = new JSONObject();

    try {//from w w w  .j av a2s .c  o  m
        JSONObject _params = new JSONObject();

        _params.put("classNameId", classNameId);
        _params.put("start", start);
        _params.put("end", end);

        _command.put("/socialactivity/get-activities", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONArray(0);
}

From source file:com.liferay.mobile.android.v7.socialactivity.SocialActivityService.java

public JSONArray getActivities(String className, int start, int end) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*from  w w  w  . j  a  va  2 s. c  om*/
        JSONObject _params = new JSONObject();

        _params.put("className", checkNull(className));
        _params.put("start", start);
        _params.put("end", end);

        _command.put("/socialactivity/get-activities", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONArray(0);
}

From source file:com.liferay.mobile.android.v7.socialactivity.SocialActivityService.java

public JSONArray getActivities(long mirrorActivityId, long classNameId, long classPK, int start, int end)
        throws Exception {
    JSONObject _command = new JSONObject();

    try {/*from   w w w. j  ava 2s . c o m*/
        JSONObject _params = new JSONObject();

        _params.put("mirrorActivityId", mirrorActivityId);
        _params.put("classNameId", classNameId);
        _params.put("classPK", classPK);
        _params.put("start", start);
        _params.put("end", end);

        _command.put("/socialactivity/get-activities", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONArray(0);
}

From source file:com.liferay.mobile.android.v7.socialactivity.SocialActivityService.java

public JSONArray getActivities(long mirrorActivityId, String className, long classPK, int start, int end)
        throws Exception {
    JSONObject _command = new JSONObject();

    try {//from   ww w  .  j  ava  2s  .  c om
        JSONObject _params = new JSONObject();

        _params.put("mirrorActivityId", mirrorActivityId);
        _params.put("className", checkNull(className));
        _params.put("classPK", classPK);
        _params.put("start", start);
        _params.put("end", end);

        _command.put("/socialactivity/get-activities", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONArray(0);
}

From source file:com.liferay.mobile.android.v7.socialactivity.SocialActivityService.java

public JSONArray getActivitySetActivities(long activitySetId, int start, int end) throws Exception {
    JSONObject _command = new JSONObject();

    try {//from w ww. java2 s.  co m
        JSONObject _params = new JSONObject();

        _params.put("activitySetId", activitySetId);
        _params.put("start", start);
        _params.put("end", end);

        _command.put("/socialactivity/get-activity-set-activities", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONArray(0);
}

From source file:com.liferay.mobile.android.v7.socialactivity.SocialActivityService.java

public JSONArray getGroupActivities(long groupId, int start, int end) throws Exception {
    JSONObject _command = new JSONObject();

    try {// w  w  w .j  a va 2s.  c o m
        JSONObject _params = new JSONObject();

        _params.put("groupId", groupId);
        _params.put("start", start);
        _params.put("end", end);

        _command.put("/socialactivity/get-group-activities", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONArray(0);
}

From source file:com.liferay.mobile.android.v7.socialactivity.SocialActivityService.java

public JSONArray getGroupUsersActivities(long groupId, int start, int end) throws Exception {
    JSONObject _command = new JSONObject();

    try {//from w  w  w .ja  v  a  2s  . c  o  m
        JSONObject _params = new JSONObject();

        _params.put("groupId", groupId);
        _params.put("start", start);
        _params.put("end", end);

        _command.put("/socialactivity/get-group-users-activities", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONArray(0);
}

From source file:com.liferay.mobile.android.v7.socialactivity.SocialActivityService.java

public JSONArray getOrganizationActivities(long organizationId, int start, int end) throws Exception {
    JSONObject _command = new JSONObject();

    try {//  ww w.j  a v  a  2  s.co  m
        JSONObject _params = new JSONObject();

        _params.put("organizationId", organizationId);
        _params.put("start", start);
        _params.put("end", end);

        _command.put("/socialactivity/get-organization-activities", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONArray(0);
}

From source file:com.liferay.mobile.android.v7.socialactivity.SocialActivityService.java

public JSONArray getOrganizationUsersActivities(long organizationId, int start, int end) throws Exception {
    JSONObject _command = new JSONObject();

    try {//from w  w w. j av  a2s  .c  o m
        JSONObject _params = new JSONObject();

        _params.put("organizationId", organizationId);
        _params.put("start", start);
        _params.put("end", end);

        _command.put("/socialactivity/get-organization-users-activities", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONArray(0);
}