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:com.liferay.mobile.android.v62.team.TeamService.java

public JSONArray getUserTeams(long userId) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*from   www.j a  va 2 s  . co m*/
        JSONObject _params = new JSONObject();

        _params.put("userId", userId);

        _command.put("/team/get-user-teams", _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.v62.team.TeamService.java

public JSONArray getUserTeams(long userId, long groupId) throws Exception {
    JSONObject _command = new JSONObject();

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

        _params.put("userId", userId);
        _params.put("groupId", groupId);

        _command.put("/team/get-user-teams", _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.ichi2.anki2.StudyOptionsFragment.java

private void createFilteredDeck(JSONArray delays, Object[] terms, Boolean resched) {
    JSONObject dyn;//from   w  w w. j a v  a2 s .  co  m
    if (AnkiDroidApp.colIsOpen()) {
        Collection col = AnkiDroidApp.getCol();
        try {
            String deckName = col.getDecks().current().getString("name");
            String customStudyDeck = getResources().getString(R.string.custom_study_deck_name);
            JSONObject cur = col.getDecks().byName(customStudyDeck);
            if (cur != null) {
                if (cur.getInt("dyn") != 1) {
                    StyledDialog.Builder builder = new StyledDialog.Builder(getActivity());
                    builder.setMessage(R.string.custom_study_deck_exists);
                    builder.setNegativeButton(getResources().getString(R.string.cancel), new OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            //
                        }
                    });
                    builder.create().show();
                    return;
                } else {
                    // safe to empty
                    col.getSched().emptyDyn(cur.getLong("id"));
                    // reuse; don't delete as it may have children
                    dyn = cur;
                    col.getDecks().select(cur.getLong("id"));
                }
            } else {
                long did = col.getDecks().newDyn(customStudyDeck);
                dyn = col.getDecks().get(did);
            }
            // and then set various options
            dyn.put("delays", delays);
            JSONArray ar = dyn.getJSONArray("terms");
            ar.getJSONArray(0).put(0,
                    new StringBuilder("deck:\"").append(deckName).append("\" ").append(terms[0]).toString());
            ar.getJSONArray(0).put(1, terms[1]);
            ar.getJSONArray(0).put(2, terms[2]);
            dyn.put("resched", resched);
            // generate cards
            finishCongrats();
            mProgressDialog = StyledProgressDialog.show(getActivity(), "",
                    getResources().getString(R.string.rebuild_custom_study_deck), true);
            DeckTask.launchDeckTask(DeckTask.TASK_TYPE_REBUILD_CRAM, mRebuildCustomStudyListener,
                    new DeckTask.TaskData(AnkiDroidApp.getCol(), AnkiDroidApp.getCol().getDecks().selected(),
                            mFragmented));
        } catch (JSONException e) {
            throw new RuntimeException(e);
        }
    }
}

From source file:com.yoncabt.ebr.util.ResultSetDeserializer.java

public List<Object[]> getData() {
    List<Object[]> ret = new ArrayList<>();
    JSONArray arr = jo.getJSONArray("values");
    for (int i = 0; i < arr.length(); i++) {
        List<Object> column = new ArrayList<>();
        JSONArray row = arr.getJSONArray(i);
        for (int j = 0; j < types.size(); j++) {
            if (row.isNull(j)) {
                column.add(null);//from  ww  w. j a  va 2  s  .  c om
            } else {
                switch (types.get(j)) {
                case DATE:
                    column.add(new Date(row.getLong(j)));
                    break;
                case STRING:
                    column.add(row.getString(j));
                    break;
                case INTEGER:
                    column.add(row.getInt(j));
                    break;
                case LONG:
                    column.add(row.getLong(j));
                    break;
                case DOUBLE:
                    column.add(row.getDouble(j));
                    break;
                default:
                    throw new AssertionError();
                }
            }
        }
        ret.add(column.toArray());
    }
    return ret;
}

From source file:com.dubsar_dictionary.Dubsar.model.Synset.java

@Override
public void parseData(Object jsonResponse) throws JSONException {
    JSONArray response = (JSONArray) jsonResponse;

    setPos(response.getString(1));/*  w w  w  .j  a  va2s .  c  om*/
    setLexname(response.getString(2));
    mGloss = response.getString(3);

    JSONArray samples = response.getJSONArray(4);
    mSamples = new ArrayList<String>(samples.length());
    int j;
    for (j = 0; j < samples.length(); ++j) {
        mSamples.add(samples.getString(j));
    }

    JSONArray senses = response.getJSONArray(5);
    mSenses = new ArrayList<Sense>(senses.length());
    for (j = 0; j < senses.length(); ++j) {
        JSONArray _sense = senses.getJSONArray(j);

        int senseId = _sense.getInt(0);
        String senseName = _sense.getString(1);

        Sense sense = new Sense(senseId, senseName, this);
        sense.setLexname(getLexname());
        if (!_sense.isNull(2)) {
            sense.setMarker(_sense.getString(2));
        }
        sense.setFreqCnt(_sense.getInt(3));

        mSenses.add(sense);
    }

    mFreqCnt = response.getInt(6);

    parsePointers(response.getJSONArray(7));
}

From source file:com.cssweb.android.view.TrendView.java

private void repairData() throws JSONException {
    close = quoteData.getDouble("close");
    high = quoteData.getDouble("high");
    low = quoteData.getDouble("low");
    jrkp = quoteData.getDouble("jrkp");

    Date dt = new Date();
    int year = dt.getYear();
    int month = dt.getMonth();
    int day = dt.getDate();
    int hour = dt.getHours();
    int minute = dt.getMinutes();
    JSONArray list = quoteData.getJSONArray("data");
    if (quoteData.getString("quotetime") != null && !quoteData.getString("quotetime").equals("")) {
        year = Integer.parseInt(quoteData.getString("quotetime").substring(0, 4));
        month = Integer.parseInt(quoteData.getString("quotetime").substring(5, 7)) - 1;
        day = Integer.parseInt(quoteData.getString("quotetime").substring(8, 10));
        hour = Integer.parseInt(quoteData.getString("quotetime").substring(11, 13));
        minute = Integer.parseInt(quoteData.getString("quotetime").substring(14, 16));
        dt = new Date(year, month, day, hour, minute);
    }/*w  w  w . jav a 2s  .co m*/
    JSONArray jsonArray = new JSONArray();
    if ("hk".equals(exchange)) {
        this.MINUTES = 300;

        Date dt1 = new Date(year, month, day, 9, 30);
        Date dt2 = new Date(year, month, day, 12, 0);
        Date dt3 = new Date(year, month, day, 13, 31);
        Date dt4 = new Date(year, month, day, 16, 0);

        long hopelen = 0;
        if (dt.getTime() < dt1.getTime()) {
            // 0 ?
            hopelen = 0;
        }
        if (dt.getTime() >= dt1.getTime() && dt.getTime() < dt2.getTime()) {
            hopelen = (dt.getTime() - dt1.getTime()) / 1000 / 60 + 1;
        }
        if (dt.getTime() >= dt2.getTime() && dt.getTime() < dt3.getTime()) {
            hopelen = 151;
        }
        if (dt.getTime() >= dt3.getTime() && dt.getTime() < dt4.getTime()) {
            hopelen = 151 + (dt.getTime() - dt3.getTime()) / 1000 / 60 + 1;
        }
        if (dt.getTime() >= dt4.getTime()) {
            hopelen = 301;
        }
        //?9.15  9.25 
        if (quoteData.getString("quotetime") == "null" || quoteData.getString("quotetime").equals("")) {
            hopelen = 1;
        }

        String time = "";
        for (int i = 0; i < hopelen; i++) {

            if (i < 151) {
                time = Utils.format(new Date(dt1.getTime() + 1000 * 60 * i));
            }
            if (i >= 151 && i <= 301) {
                time = Utils.format(new Date(dt3.getTime() + 1000 * 60 * (i - 151)));
            }
            Boolean flag = false;

            JSONArray json = new JSONArray();
            for (int j = 0; j < list.length(); j++) {
                if (list.getJSONArray(j).getString(3).equals(time)) {
                    json.put(0, list.getJSONArray(j).getDouble(0));
                    json.put(1, list.getJSONArray(j).getDouble(1));
                    json.put(2, list.getJSONArray(j).getDouble(2));
                    json.put(3, list.getJSONArray(j).getString(3));
                    json.put(4, 1);//??
                    if (i == 0) {
                        json.put(5, list.getJSONArray(j).getDouble(1));//??
                        json.put(6, list.getJSONArray(j).getDouble(2));//??
                    } else {
                        if (jsonArray.getJSONArray(i - 1).getInt(4) == 1) {
                            json.put(5, list.getJSONArray(j).getDouble(1)
                                    - jsonArray.getJSONArray(i - 1).getInt(1));
                            json.put(6, list.getJSONArray(j).getDouble(2)
                                    - jsonArray.getJSONArray(i - 1).getInt(2));
                        } else {
                            json.put(5, 0);
                            json.put(6, 0);
                        }
                    }
                    //json.put(7, (list.getJSONArray(j).getDouble(2)/list.getJSONArray(j).getDouble(1))/100);//?
                    flag = true;
                    break;
                }
            }
            //?
            if (!flag) {
                if (i == 0) {
                    json.put(1, 0);
                    json.put(2, 0);
                    json.put(3, time);
                    json.put(0, quoteData.getDouble("close"));
                } else {
                    json.put(1, jsonArray.getJSONArray(i - 1).getDouble(1));
                    json.put(2, jsonArray.getJSONArray(i - 1).getDouble(2));
                    json.put(3, time);
                    json.put(0, ((JSONArray) jsonArray.get(i - 1)).getDouble(0));
                }
                json.put(4, 0);
                json.put(5, 0);
                json.put(6, 0);
                json.put(7, 0);
            }
            jsonArray.put(json);
        }
    } else if ("cf".equals(exchange)) {
        this.MINUTES = 270;

        Date dt1 = new Date(year, month, day, 9, 15);
        Date dt2 = new Date(year, month, day, 11, 30);
        Date dt3 = new Date(year, month, day, 13, 1);
        Date dt4 = new Date(year, month, day, 15, 15);

        long hopelen = 0;
        if (dt.getTime() < dt1.getTime()) {
            // 0 ?
            hopelen = 0;
        }
        if (dt.getTime() >= dt1.getTime() && dt.getTime() < dt2.getTime()) {
            hopelen = (dt.getTime() - dt1.getTime()) / 1000 / 60 + 1;
        }
        if (dt.getTime() >= dt2.getTime() && dt.getTime() < dt3.getTime()) {
            hopelen = 136;
        }
        if (dt.getTime() >= dt3.getTime() && dt.getTime() < dt4.getTime()) {
            hopelen = 136 + (dt.getTime() - dt3.getTime()) / 1000 / 60 + 1;
        }
        if (dt.getTime() >= dt4.getTime()) {
            hopelen = 271;
        }
        //?9.15  9.25 
        if (quoteData.getString("quotetime") == "null") {
            hopelen = 0;
        }

        String time = "";
        for (int i = 0; i < hopelen; i++) {

            if (i < 136) {
                time = Utils.format(new Date(dt1.getTime() + 1000 * 60 * i));
            }
            if (i >= 136 && i <= 271) {
                time = Utils.format(new Date(dt3.getTime() + 1000 * 60 * (i - 136)));
            }
            Boolean flag = false;

            JSONArray json = new JSONArray();
            for (int j = 0; j < list.length(); j++) {
                if (list.getJSONArray(j).getString(3).equals(time)) {
                    json.put(0, list.getJSONArray(j).getDouble(0));
                    json.put(1, list.getJSONArray(j).getDouble(1));
                    json.put(2, list.getJSONArray(j).getDouble(2));
                    json.put(3, list.getJSONArray(j).getString(3));
                    json.put(4, 1);//??
                    if (i == 0) {
                        json.put(5, list.getJSONArray(j).getDouble(1));//??
                        json.put(6, list.getJSONArray(j).getDouble(2));//??
                    } else {
                        if (jsonArray.getJSONArray(i - 1).getInt(4) == 1) {
                            json.put(5, list.getJSONArray(j).getDouble(1)
                                    - jsonArray.getJSONArray(i - 1).getInt(1));
                            json.put(6, list.getJSONArray(j).getDouble(2)
                                    - jsonArray.getJSONArray(i - 1).getInt(2));
                        } else {
                            json.put(5, 0);
                            json.put(6, 0);
                        }
                    }
                    //json.put(7, (list.getJSONArray(j).getDouble(2)/list.getJSONArray(j).getDouble(1))/100);//?
                    flag = true;
                    break;
                }
            }
            //?
            if (!flag) {
                if (i == 0) {
                    json.put(1, 0);
                    json.put(2, 0);
                    json.put(3, time);
                    json.put(0, quoteData.getDouble("jrkp"));
                } else {
                    json.put(1, jsonArray.getJSONArray(i - 1).getDouble(1));
                    json.put(2, jsonArray.getJSONArray(i - 1).getDouble(2));
                    json.put(3, time);
                    json.put(0, ((JSONArray) jsonArray.get(i - 1)).getDouble(0));
                }
                json.put(4, 0);
                json.put(5, 0);
                json.put(6, 0);
                json.put(7, 0);
            }
            jsonArray.put(json);
        }
    } else if ("dc".equals(exchange) || "sf".equals(exchange) || "cz".equals(exchange)) {
        this.MINUTES = 225;

        Date dt1 = new Date(year, month, day, 9, 0);
        Date dt2 = new Date(year, month, day, 10, 15);
        Date dt3 = new Date(year, month, day, 10, 31);
        Date dt4 = new Date(year, month, day, 11, 30);
        Date dt5 = new Date(year, month, day, 13, 31);
        Date dt6 = new Date(year, month, day, 15, 0);

        long hopelen = 0;
        if (dt.getTime() < dt1.getTime()) {
            // 0 ?
            hopelen = 0;
        }
        if (dt.getTime() >= dt1.getTime() && dt.getTime() < dt2.getTime()) {
            hopelen = (dt.getTime() - dt1.getTime()) / 1000 / 60 + 1;
        }
        if (dt.getTime() >= dt2.getTime() && dt.getTime() < dt3.getTime()) {
            hopelen = 76;
        }
        if (dt.getTime() >= dt3.getTime() && dt.getTime() < dt4.getTime()) {
            hopelen = 76 + (dt.getTime() - dt3.getTime()) / 1000 / 60 + 1;
        }
        if (dt.getTime() >= dt4.getTime() && dt.getTime() < dt5.getTime()) {
            hopelen = 136;
        }
        if (dt.getTime() >= dt5.getTime() && dt.getTime() < dt6.getTime()) {
            hopelen = 136 + (dt.getTime() - dt5.getTime()) / 1000 / 60 + 1;
        }
        if (dt.getTime() >= dt6.getTime()) {
            hopelen = 226;
        }
        //?9.15  9.25 
        if (quoteData.getString("quotetime") == "null") {
            hopelen = 0;
        }

        String time = "";
        for (int i = 0; i < hopelen; i++) {

            if (i < 76) {
                time = Utils.format(new Date(dt1.getTime() + 1000 * 60 * i));
            }
            if (i >= 76 && i < 136) {
                time = Utils.format(new Date(dt3.getTime() + 1000 * 60 * (i - 76)));
            }
            if (i >= 136 && i <= 226) {
                time = Utils.format(new Date(dt5.getTime() + 1000 * 60 * (i - 136)));
            }
            Boolean flag = false;
            JSONArray json = new JSONArray();
            for (int j = 0; j < list.length(); j++) {
                if (list.getJSONArray(j).getString(3).equals(time)) {
                    json.put(0, list.getJSONArray(j).getDouble(0));
                    json.put(1, list.getJSONArray(j).getDouble(1));
                    json.put(2, list.getJSONArray(j).getDouble(2));
                    json.put(3, list.getJSONArray(j).getString(3));
                    json.put(4, 1);//??
                    if (i == 0) {
                        json.put(5, list.getJSONArray(j).getDouble(1));//??
                        json.put(6, list.getJSONArray(j).getDouble(2));//??
                    } else {
                        if (jsonArray.getJSONArray(i - 1).getInt(4) == 1) {
                            json.put(5, list.getJSONArray(j).getDouble(1)
                                    - jsonArray.getJSONArray(i - 1).getInt(1));
                            json.put(6, list.getJSONArray(j).getDouble(2)
                                    - jsonArray.getJSONArray(i - 1).getInt(2));
                        } else {
                            json.put(5, 0);
                            json.put(6, 0);
                        }
                    }
                    //json.put(7, (list.getJSONArray(j).getDouble(2)/list.getJSONArray(j).getDouble(1))/100);//?
                    flag = true;
                    break;
                }
            }
            //?
            if (!flag) {
                if (i == 0) {
                    json.put(1, 0);
                    json.put(2, 0);
                    json.put(3, time);
                    json.put(0, quoteData.getDouble("jrkp"));
                } else {
                    json.put(1, jsonArray.getJSONArray(i - 1).getDouble(1));
                    json.put(2, jsonArray.getJSONArray(i - 1).getDouble(2));
                    json.put(3, time);
                    json.put(0, ((JSONArray) jsonArray.get(i - 1)).getDouble(0));
                }
                json.put(4, 0);
                json.put(5, 0);
                json.put(6, 0);
                json.put(7, 0);
            }
            jsonArray.put(json);
        }
    } else {
        Date dt1 = new Date(year, month, day, 9, 30);
        Date dt2 = new Date(year, month, day, 11, 30);
        Date dt3 = new Date(year, month, day, 13, 1);
        Date dt4 = new Date(year, month, day, 15, 0);

        long hopelen = 0;
        if (dt.getTime() < dt1.getTime()) {
            // 0 ?
            hopelen = 0;
        }
        if (dt.getTime() >= dt1.getTime() && dt.getTime() < dt2.getTime()) {
            hopelen = (dt.getTime() - dt1.getTime()) / 1000 / 60 + 1;
        }
        if (dt.getTime() >= dt2.getTime() && dt.getTime() < dt3.getTime()) {
            hopelen = 121;
        }
        if (dt.getTime() >= dt3.getTime() && dt.getTime() < dt4.getTime()) {
            hopelen = 121 + (dt.getTime() - dt3.getTime()) / 1000 / 60 + 1;
        }
        if (dt.getTime() >= dt4.getTime()) {
            hopelen = 241;
        }
        //?9.15  9.25 
        if (quoteData.getString("quotetime") == "null") {
            hopelen = 0;
        }

        String time = "";
        for (int i = 0; i < hopelen; i++) {

            if (i < 121) {
                time = Utils.format(new Date(dt1.getTime() + 1000 * 60 * i));
            }
            if (i >= 121 && i <= 241) {
                time = Utils.format(new Date(dt3.getTime() + 1000 * 60 * (i - 121)));
            }
            Boolean flag = false;

            JSONArray json = new JSONArray();
            for (int j = 0; j < list.length(); j++) {
                if (list.getJSONArray(j).getString(3).equals(time)) {
                    json.put(0, list.getJSONArray(j).getDouble(0));
                    json.put(1, list.getJSONArray(j).getDouble(1));
                    json.put(2, list.getJSONArray(j).getDouble(2));
                    json.put(3, list.getJSONArray(j).getString(3));
                    json.put(4, 1);//??
                    if (i == 0) {
                        json.put(5, list.getJSONArray(j).getDouble(1));//??
                        json.put(6, list.getJSONArray(j).getDouble(2));//??
                    } else {
                        if (jsonArray.getJSONArray(i - 1).getInt(4) == 1) {
                            json.put(5, list.getJSONArray(j).getDouble(1)
                                    - jsonArray.getJSONArray(i - 1).getInt(1));
                            json.put(6, list.getJSONArray(j).getDouble(2)
                                    - jsonArray.getJSONArray(i - 1).getInt(2));
                        } else {
                            json.put(5, 0);
                            json.put(6, 0);
                        }
                    }
                    //json.put(7, (list.getJSONArray(j).getDouble(2)/list.getJSONArray(j).getDouble(1))/100);//?
                    flag = true;
                    break;
                }
            }
            //?
            if (!flag) {
                if (i == 0) {
                    json.put(1, 0);
                    json.put(2, 0);
                    json.put(3, time);
                    json.put(0, quoteData.getDouble("close"));
                } else {
                    json.put(1, jsonArray.getJSONArray(i - 1).getDouble(1));
                    json.put(2, jsonArray.getJSONArray(i - 1).getDouble(2));
                    json.put(3, time);
                    json.put(0, ((JSONArray) jsonArray.get(i - 1)).getDouble(0));
                }
                json.put(4, 0);
                json.put(5, 0);
                json.put(6, 0);
                json.put(7, 0);
            }
            jsonArray.put(json);
        }
    }
    //Log.i("#########getSecurityType##########", NameRule.getSecurityType(exchange, stockcode)+">>>>>>>>>>>>>>");
    //      if(NameRule.getSecurityType(exchange, stockcode)==15 
    //            || NameRule.getSecurityType(exchange, stockcode)==5
    //            || NameRule.getSecurityType(exchange, stockcode)==35){
    //         quoteArray = null; 
    //         return;
    //      }else{
    //         quoteArray = jsonArray; 
    //      }
    quoteArray = jsonArray;

    actualDataLen = quoteArray.length();
    if (!isTrackStatus)
        isTrackNumber = actualDataLen - 1;//??

    highvolume = TickUtil.gethighVolume(quoteArray);
    highamount = TickUtil.gethighAmount(quoteArray);
    high = Math.max(TickUtil.gethighPrice(quoteArray, quoteArray.length()), close);
    low = Math.min(TickUtil.getlowPrice(quoteArray, quoteArray.length()), close);
    if ("sz399001".equals(exchange + stockcode) || "sh000001".equals(exchange + stockcode)) {
        //??????
        int len = quoteData.getJSONArray("data2").length() - 1;
        high = Math.max(high, TickUtil.gethighPrice(quoteData.getJSONArray("data2"), len));
        low = Math.min(low, TickUtil.getlowPrice(quoteData.getJSONArray("data2"), len));
    }
}

From source file:com.liferay.mobile.android.v62.shoppingcategory.ShoppingCategoryService.java

public JSONArray getCategories(long groupId) throws Exception {
    JSONObject _command = new JSONObject();

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

        _params.put("groupId", groupId);

        _command.put("/shoppingcategory/get-categories", _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.v62.shoppingcategory.ShoppingCategoryService.java

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

    try {/*from   w w w.j a  v  a2 s  .c o m*/
        JSONObject _params = new JSONObject();

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

        _command.put("/shoppingcategory/get-categories", _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:reittienEtsinta.tiedostonKasittely.GeoJsonLukija.java

private Polygoni luoPolygoni(int maasto, JSONArray pisteet, Polygoni uusi) {

    for (int i = 0; i < pisteet.length(); i++) {
        uusi.lisaaPiste(pisteet.getJSONArray(i).getDouble(1), pisteet.getJSONArray(i).getDouble(0),
                this.pisteita);
        this.pisteita++;
    }/* www .  ja va2  s.  c  o m*/
    uusi.setMaasto(maasto);
    return uusi;
}

From source file:com.liferay.mobile.android.v62.country.CountryService.java

public JSONArray getCountries() throws Exception {
    JSONObject _command = new JSONObject();

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

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

    JSONArray _result = session.invoke(_command);

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

    return _result.getJSONArray(0);
}