Java Code Examples for org.json.JSONObject.getJSONArray()

The following are Jave code examples for showing how to use getJSONArray() of the org.json.JSONObject class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: letv   File: TaskGuide.java   View Source Code Vote up 9 votes
static h a(JSONObject jSONObject) throws JSONException {
    if (jSONObject == null) {
        return null;
    }
    h hVar = new h();
    JSONObject jSONObject2 = jSONObject.getJSONObject("task_info");
    hVar.a = jSONObject2.getString("task_id");
    hVar.b = jSONObject2.getString("task_desc");
    JSONArray jSONArray = jSONObject2.getJSONArray("step_info");
    int length = jSONArray.length();
    if (length > 0) {
        hVar.c = new g[length];
    }
    for (int i = 0; i < length; i++) {
        jSONObject2 = jSONArray.getJSONObject(i);
        hVar.c[i] = new g(jSONObject2.getInt("step_no"), jSONObject2.getString("step_desc"), jSONObject2.getString("step_gift"), jSONObject2.getLong("end_time"), jSONObject2.getInt("status"));
    }
    return hVar;
}
 
Example 2
Project: browser   File: JSONUtil.java   View Source Code Vote up 8 votes
public static String[] getArrayString(JSONObject docObj, String name) {
	String[] list = null;
	if (docObj.has(name)) {
		JSONArray json;
		try {
			json = docObj.getJSONArray(name);
			int lenFeatures = json.length();
			list = new String[lenFeatures];
			for (int j = 0; j < lenFeatures; j++) {
				String f = json.getString(j);
				list[j] = f;
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}

	}
	return list;

}
 
Example 3
Project: yyox   File: OrderModel.java   View Source Code Vote up 6 votes
@Override
public Observable<List<QuestionItem>> getQuestionItems(String value) {
    List<QuestionItem> questionItems = new ArrayList<QuestionItem>();

    try {
        JSONObject jsonObject = new JSONObject(value);
        JSONArray array = jsonObject.getJSONArray("data");
        for (int i = 0; i < array.length(); i++) {
            JSONObject object = array.getJSONObject(i);
            JSONArray array1 = object.getJSONArray("list");
            List<Question> questions = new ArrayList<Question>();
            for (int j = 0; j < array1.length(); j++) {
                JSONObject object1 = array1.getJSONObject(j);
                Question question = new Question();
                question.setAnswer(object1.getString("desc"));
                question.setQuestion(object1.getString("title"));
                questions.add(question);
            }
            QuestionItem questionItem = new QuestionItem();
            questionItem.setName(object.getString("category"));
            questionItem.setQuestion(questions);
            questionItems.add(questionItem);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

    return Observable.just(questionItems);
}
 
Example 4
Project: Nearby   File: PatientPhoto.java   View Source Code Vote up 6 votes
public void build(String data){

        try {
            // PHP에서 받아온 JSON 데이터를 JSON오브젝트로 변환
            JSONObject jObject = new JSONObject(data);
            // results라는 key는 JSON배열로 되어있다.
            JSONArray results = jObject.getJSONArray("result");
            String countTemp = (String)jObject.get("num_result");
            int count = Integer.parseInt(countTemp);

            for ( int i = 0; i < count; ++i ) {
                JSONObject temp = results.getJSONObject(i);
                convert(temp);

            }

        } catch (JSONException e) {
            e.printStackTrace();
        }

    }
 
Example 5
Project: sstore-soft   File: AggregatePlanNode.java   View Source Code Vote up 6 votes
@Override
protected void loadFromJSONObject(JSONObject obj, Database db) throws JSONException {
    JSONArray aggregateColumns = obj.getJSONArray(Members.AGGREGATE_COLUMNS.name());
    for (int ii = 0; ii < aggregateColumns.length(); ii++) {
        JSONObject aggregateColumn = aggregateColumns.getJSONObject(ii);
        m_aggregateTypes.add(ExpressionType.valueOf(aggregateColumn.getString(Members.AGGREGATE_TYPE.name())));
        m_aggregateColumnNames.add(aggregateColumn.getString(Members.AGGREGATE_NAME.name()));
        m_aggregateColumnGuids.add(aggregateColumn.getInt(Members.AGGREGATE_GUID.name()));
        m_aggregateOutputColumns.add(aggregateColumn.getInt(Members.AGGREGATE_OUTPUT_COLUMN.name()));
    }
    
    try {
        JSONArray groupbyColumnGuids = obj.getJSONArray(Members.GROUPBY_COLUMNS.name());
        for (int ii = 0; ii < groupbyColumnGuids.length(); ii++) {
            JSONObject jsonObject = groupbyColumnGuids.getJSONObject(ii);
            PlanColumn column = PlanColumn.fromJSONObject(jsonObject, db);
            m_groupByColumnGuids.add(column.guid());
        }
    } catch (JSONException e) {
        //okay not to be there.
    }
}
 
Example 6
Project: letv   File: RedPacketParser.java   View Source Code Vote up 6 votes
public RedPacketBean parser(JSONObject data) throws Exception {
    parsePollingController(data);
    RedPacketBean bean = new RedPacketBean();
    if (has(data, "blockContent")) {
        JSONArray jsonArray = data.getJSONArray("blockContent");
        if (!(jsonArray == null || jsonArray.length() == 0)) {
            RedPacketSdkManager.getInstance().setRedPacketList(jsonArray);
        }
        bean = parserRedPacketList(jsonArray);
        bean.type = RedPacketBean.TYPE_REDPACKET;
    }
    this.mPollingResult.hasRedPacket = RedPacketSdkManager.getInstance().hasRedPacket(bean);
    if (this.mCallback != null) {
        this.mCallback.onReceivePollingResult(this.mPollingResult);
        this.mCallback = null;
    }
    LogInfo.log("RedPacketParser", "parser + Network is ok,parse polling result is finish");
    return bean;
}
 
Example 7
Project: AndroidProgramming3e   File: FlickrFetchr.java   View Source Code Vote up 6 votes
private void parseItems(List<GalleryItem> items, JSONObject jsonBody)
        throws IOException, JSONException {

    JSONObject photosJsonObject = jsonBody.getJSONObject("photos");
    JSONArray photoJsonArray = photosJsonObject.getJSONArray("photo");

    for (int i = 0; i < photoJsonArray.length(); i++) {
        JSONObject photoJsonObject = photoJsonArray.getJSONObject(i);

        GalleryItem item = new GalleryItem();
        item.setId(photoJsonObject.getString("id"));
        item.setCaption(photoJsonObject.getString("title"));
        
        if (!photoJsonObject.has("url_s")) {
            continue;
        }
        
        item.setUrl(photoJsonObject.getString("url_s"));
        items.add(item);
    }
}
 
Example 8
Project: sstore-soft   File: PlanNodeList.java   View Source Code Vote up 5 votes
protected void loadFromJSONObject(JSONObject object, Database db) throws JSONException {
    super.loadFromJSONObject(object, db);
    JSONArray executeList = object.getJSONArray(Members.EXECUTE_LIST.name());
    for (int ii = 0; ii < executeList.length(); ii++) {
        Integer id = executeList.getInt(ii);
        m_list.add(m_idToNodeMap.get(id));
    }
}
 
Example 9
Project: open-rmbt   File: QoSServerResultDesc.java   View Source Code Vote up 5 votes
/**
 * 
 * @param json
 * @throws JSONException
 */
public QoSServerResultDesc(JSONObject json) throws JSONException {
	this.desc = json.getString(JSON_KEY_DESCRIPTION);
	this.testType = QoSTestResultEnum.valueOf(json.getString(JSON_KEY_TESTTYPE));
	this.status = DetailType.valueOf(json.getString(JSON_KEY_STATUS).toUpperCase(Locale.US));
	JSONArray uidArray = json.getJSONArray(JSON_KEY_UID_LIST);
	for (int i = 0; i < uidArray.length(); i++) {
		uidSet.add(uidArray.getLong(i));
	}
}
 
Example 10
Project: boohee_v5.6   File: UserConnection.java   View Source Code Vote up 5 votes
public static ArrayList<UserConnection> parseUserConnections(JSONObject object) {
    ArrayList<UserConnection> connections = null;
    try {
        JSONArray connObj = object.getJSONArray("user_connections");
        return (ArrayList) new Gson().fromJson(connObj.toString(), new
                TypeToken<ArrayList<UserConnection>>() {
        }.getType());
    } catch (JSONException e) {
        e.printStackTrace();
        return connections;
    }
}
 
Example 11
Project: EsperantoRadio   File: MuOnlineBackend.java   View Source Code Vote up 5 votes
ArrayList<Lydstream> parsStreams(JSONObject jsonobj) throws JSONException {
  ArrayList<Lydstream> lydData = new ArrayList<>();

  String subtitles = null;
  JSONArray jsonArraySubtitles = jsonobj.optJSONArray("SubtitlesList"); //Forventer den kan være tom
  if (jsonArraySubtitles != null) {
    //Antagelse: Vil altid kun være 1 subtitle, på dansk. Dog tjekkes det i et for-loop og leder efter dansk, hvis nu antagelsen er forkert.
    for (int i = 0; i < jsonArraySubtitles.length(); i++) {
      JSONObject jsonSubtitles = jsonArraySubtitles.getJSONObject(i);
      if (jsonSubtitles.getString("Language").equals("Danish")) {
        subtitles = jsonSubtitles.getString("Uri");
      } else Log.d("Findes andre subtitles på sprog: " + jsonSubtitles.getString("Language"));
    }
  }

  JSONArray jsonArrayStreams = jsonobj.getJSONArray("Links");
  for (int k = 0; k < jsonArrayStreams.length(); k++) {
    JSONObject jsonStream = jsonArrayStreams.getJSONObject(k);
    String type = jsonStream.getString("Target");
    if ("HDS".equals(type)) continue; // HDS (HTTP Dynamic Streaming fra Adobe) kan ikke afspilles på Android

    //if (App.fejlsøgning) Log.d("streamjson=" + jsonStream);
    Lydstream l = new Lydstream();
    l.url = jsonStream.getString("Uri");

    if ("Download".equals(type)) {
      l.type = Lydstream.StreamType.HTTP_Download;
      l.bitrate_ubrugt = jsonStream.getInt("Bitrate");
    } else {
      l.type = Lydstream.StreamType.HLS_fra_Akamai;
    }
    l.kvalitet = Lydstream.StreamKvalitet.Variabel;
    l.subtitlesUrl = subtitles;
    lydData.add(l);
  }
  return lydData;
}
 
Example 12
Project: CoolCloud-Weather   File: Utility.java   View Source Code Vote up 5 votes
/**
 *
 * 处理得到的 weather 数据,转化为 weather 对象
 */
public static Weather handleWeatherResponse(String response){
    try{
        JSONObject jsonObject = new JSONObject(response);
        JSONArray jsonArray = jsonObject.getJSONArray("HeWeather5");
        String weatherContent = jsonArray.getJSONObject(0).toString();
        return new Gson().fromJson(weatherContent, Weather.class);
    }catch (Exception e){
        e.printStackTrace();
    }
    return null;
}
 
Example 13
Project: Sega   File: CommentFragment.java   View Source Code Vote up 4 votes
private void downloadComment() {
    StringRequest strReq = new StringRequest(Request.Method.POST,
            AppConfig.URL_COMMENTS, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            try {
                JSONObject jObj = new JSONObject(response);
                JSONArray feedArray = jObj.getJSONArray("comments");
                adapter.CommentsList.clear();
                for (int i = 0; i < feedArray.length(); i++) {
                    final JSONObject feedComment = (JSONObject) feedArray.get(i);
                    //add product to list products
                    Comments comment = new Comments(feedComment.getString("userid"), feedComment.getString("username"), feedComment.getString("time"),
                                                    feedComment.getString("contentcomment"), feedComment.getString("userpic"), feedComment.getString("rate"));
                    adapter.CommentsList.add(comment);
                }
                // Load detail fragment if in tablet mode
                commentView.setAdapter(adapter);
                adapter.notifyDataSetChanged();

            } catch (Exception ex) {
                // JSON parsing error
                ex.printStackTrace();
            }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            error.printStackTrace();
        }
    }) {
        @Override
        protected Map<String, String> getParams() {
            // Posting parameters to login url
            Map<String, String> params = new HashMap<>();
            params.put("userid", userid + "");
            return params;
        }
    };
    strReq.setTag(this.getClass().getName());
    VolleySingleton.getInstance(getActivity()).requestQueue.add(strReq);
}
 
Example 14
Project: CodeMania   File: Userdata.java   View Source Code Vote up 4 votes
protected void onPostExecute(String response) {
            if (response == null) {
                response = "THERE WAS AN ERROR";
            }
            progressBar.setVisibility(View.GONE);
            Log.i("INFO", response);
            //responseView.setText(response);
            try {
                JSONObject object = (JSONObject) new JSONTokener(response).nextValue();
                JSONArray obj1 = object.getJSONArray("result");
                JSONObject obj = obj1.getJSONObject(0);
                //   String email1 = obj.getString("country");
                // System.out.println(email1);
                int rating1 = 0, maxrating1 = 0;
                String country1 = null, city1 = null, contribution1 = null, firstname = null, lastname = null;
                if (obj.has("rating"))
                    rating1 = obj.getInt("rating");
                if (rating1 != 0)
                    rating.setText(rating1 + "");
                else rating.setText("Not Found ");
                if (obj.has("country"))
                    country1 = obj.getString("country");
                else country1 = "Not Found ";
                country.setText(country1);
                if (obj.has("city"))
                    city1 = obj.getString("city");
                else city1 = "Not Found ";
                city.setText(city1);
                if (obj.has("maxRating"))
                    maxrating1 = obj.getInt("maxRating");
                if (maxrating1 != 0)
                    maxrating.setText(maxrating1 + "");
                else maxrating.setText("Not Found");
                if (obj.has("contribution"))
                    contribution1 = obj.getString("contribution");
                else contribution1 = "Not Found";
                contribution.setText(contribution1);
                if (obj.has("firstName"))
                    firstname = obj.getString("firstName");
                else firstname = "Not Found";
                if (obj.has("lastName"))
                    lastname = obj.getString("lastName");
                else lastname = "";
                username.setText(firstname + " " + lastname);
                submission.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        String url = "http://codeforces.com/submissions/" + handle.getText().toString();
                    }
                });
            } catch (JSONException e) {
                e.printStackTrace();
            }


//            try {
//                JSONObject object = (JSONObject) new JSONTokener(response).nextValue();
//                String requestID = object.getString("requestId");
//                int likelihood = object.getInt("likelihood");
//                JSONArray photos = object.getJSONArray("photos");
//                .
//                .
//                .
//                .
//            } catch (JSONException e) {
//                e.printStackTrace();
//            }
        }
 
Example 15
Project: IdealMedia   File: TaskGetArtwork.java   View Source Code Vote up 4 votes
public void getArtwork(Track track) {
    final String currentArtist = "" + track.getArtist();

    if (currentArtist.equals(""))
        return;

    if (MediaUtils.getArtworkQuick(context, track, 300, 300) != null)
        return;

    if (activeTasks.size() > 2)
        return;

    if (activeTasks.containsKey(currentArtist))
        return;

    activeTasks.put(currentArtist, this);

    AQuery aq = new AQuery(context);
    String url = String.format("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&api_key=683548928700d0cdc664691b862a8d21&artist=%s&format=json", Uri.encode(currentArtist));
    AjaxCallback<JSONObject> cb = new AjaxCallback<JSONObject>();
    cb.url(url).type(JSONObject.class).fileCache(true).expire(3600 * 60 * 1000);
    aq.sync(cb);
    JSONObject result = cb.getResult();

    if (result != null) {
        JSONObject jsonObject = null;
        String albumArtImageLink = null;
        try {
            if (!result.has("artist"))
                return;

            jsonObject = result.getJSONObject("artist");
            JSONArray image = jsonObject.getJSONArray("image");
            for (int i=0;i<image.length();i++) {
                jsonObject = image.getJSONObject(i);
                if (jsonObject.getString("size").equals("extralarge")) {
                    albumArtImageLink = Uri.decode(jsonObject.getString("#text"));
                }
            }
            if (!(albumArtImageLink != null && albumArtImageLink.equals(""))) {
                String path = MediaUtils.getArtistPath(track);
                if (path != null) {
                    File file = new File(path);

                    AjaxCallback<File> cbFile = new AjaxCallback<File>();
                    cbFile.url(albumArtImageLink).type(File.class).targetFile(file);
                    aq.sync(cbFile);

                    AjaxStatus status = cbFile.getStatus();
                    if (status.getCode() == 200) {
                        if (listener != null)
                            listener.onNewArtwork();
                    } else {
                        file.delete();
                    }
                }
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
    activeTasks.remove(currentArtist);
}
 
Example 16
Project: alfresco-remote-api   File: AclsGet.java   View Source Code Vote up 4 votes
private Map<String, Object> buildModel(WebScriptRequest req) throws JSONException, IOException
{
    List<Long> aclChangeSetIds = null;
    
    Content content = req.getContent();
    if (content == null)
    {
        throw new WebScriptException("Request content is empty");
    }
    JSONObject o = new JSONObject(content.getContent());
    JSONArray aclChangeSetIdsJSON = o.has("aclChangeSetIds") ? o.getJSONArray("aclChangeSetIds") : null;
    if (aclChangeSetIdsJSON == null)
    {
        throw new WebScriptException(
                Status.STATUS_BAD_REQUEST,
                "Parameter 'aclChangeSetIds' not provided in request content.");
    }
    else if (aclChangeSetIdsJSON.length() == 0)
    {
        throw new WebScriptException(
                Status.STATUS_BAD_REQUEST,
                "Parameter 'aclChangeSetIds' must hold from 1 or more IDs.");
    }
    aclChangeSetIds = new ArrayList<Long>(aclChangeSetIdsJSON.length());
    for (int i = 0; i < aclChangeSetIdsJSON.length(); i++)
    {
        aclChangeSetIds.add(aclChangeSetIdsJSON.getLong(i));
    }

    String fromIdParam = req.getParameter("fromId");
    String maxResultsParam = req.getParameter("maxResults");

    Long fromId = (fromIdParam == null ? null : Long.valueOf(fromIdParam));
    int maxResults = (maxResultsParam == null ? 1024 : Integer.valueOf(maxResultsParam));
    
    // Request according to the paging query style required
    List<Acl> acls = solrTrackingComponent.getAcls(aclChangeSetIds, fromId, maxResults);
    
    Map<String, Object> model = new HashMap<String, Object>(1, 1.0f);
    model.put("acls", acls);

    if (logger.isDebugEnabled())
    {
        logger.debug("Result: \n\tRequest: " + req + "\n\tModel: " + model);
    }
    
    return model;
}
 
Example 17
Project: marathonv5   File: JavaServer.java   View Source Code Vote up 4 votes
public Object executeAsync(JSONObject query, JSONObject uriParams, Session session) {
    checkRequiredArguments(query, "script", "args");
    JSONScriptRunner scriptRunner = new JSONScriptRunner(query.getString("script"), query.getJSONArray("args"), session,
            ExecuteMode.ASYNC);
    return scriptRunner.execute();
}
 
Example 18
Project: PixivForMuzeiPlus   File: Pixiv.java   View Source Code Vote up 4 votes
public List getBooklist(){
    ArrayList list= new ArrayList();
    HttpUtil book;
    String tempurl=BOOK_URL+userid;

    for(int j=0;j<9;j++) {
        book = new HttpUtil(tempurl, cookie);
        book.checkURL();

        Map<String, String> recprer = basepre;
        recprer.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
        restring = book.getData(recprer);
        if (restring.equals("ERROR")) {
            error = "1041";
            return null;
        }

        try {
            restring = restring.replaceFirst("null", "");
            Log.i(TAG, restring);
            JSONObject o = new JSONObject(restring);
            JSONArray ill = o.getJSONArray("illusts");
            for (int i = 0; i < ill.length(); i++) {
                JSONObject t = ill.getJSONObject(i);
                list.add(t.get("id"));
            }
            tempurl=o.getString("next_url");
            if(o.isNull("next_url")){
                break;
            }

        } catch (JSONException e) {
            Log.e(TAG, e.toString(), e);
            error = "1042";
            return null;
        }

    }

    return list;
}
 
Example 19
Project: Fatigue-Detection   File: FilterFactory.java   View Source Code Vote up 4 votes
public static MakeupData parseMakeUpInfo(String paramString, JSONObject paramJSONObject)
        throws IOException, JSONException {
    MakeupData locala = new MakeupData();
    locala.ep = paramJSONObject.getInt("resloadtype");
    locala.name = paramJSONObject.getString("foldername");
    locala.cN = paramJSONObject.getInt("maxcount");
    JSONArray localJSONArray1 = paramJSONObject.getJSONArray("triangles");
    locala.cN = Math.min(localJSONArray1.length(), locala.cN);

    locala.eo = new ArrayList();
    for (int i = 0; i < locala.cN; i++) {
        MakeupData.a locala1 = new MakeupData.a();
        JSONObject localJSONObject = localJSONArray1.getJSONObject(i);

        locala1.eq = localJSONObject.getString("res");
        JSONArray localJSONArray2 = localJSONObject.getJSONArray("vertexIndexes");
        locala1.er = new int[localJSONArray2.length()];
        for (int j = 0; j < localJSONArray2.length(); j++) {
            locala1.er[j] = localJSONArray2.getInt(j);
        }
        JSONArray localJSONArray3 = localJSONObject.optJSONArray("facePointOffset");
        if (null != localJSONArray3) {
            if (localJSONArray3.length() % 5 != 0) {
                throw new JSONException("facePointOffset is not multiple of 5");
            }
            locala1.es = new MakeupData.b[localJSONArray3.length() / 5];
            for (int k = 0; k < locala1.es.length; k++) {
                MakeupData.b localb = new MakeupData.b();
                localb.ew = localJSONArray3.getInt(5 * k);
                localb.ex = localJSONArray3.getInt(5 * k + 1);
                localb.ey = ((float) localJSONArray3.getDouble(5 * k + 2));
                localb.ez = localJSONArray3.getInt(5 * k + 3);
                localb.eA = ((float) localJSONArray3.getDouble(5 * k + 4));
                locala1.es[k] = localb;
            }
        } else {
            locala1.es = new MakeupData.b[0];
        }
        JSONArray localJSONArray4 = localJSONObject.getJSONArray("resFacePoints");
        if (localJSONArray4.length() != 212) {
            throw new JSONException("resFacePoints size is error");
        }
        locala1.et = new PointF[106];
        for (int m = 0; m < 106; m++) {
            locala1.et[m] = new PointF((float) localJSONArray4.getDouble(2 * m), (float) localJSONArray4.getDouble(2 * m + 1));
        }
        locala1.ev = (localJSONObject.optInt("inheritoffset") == 1);
        locala.eo.add(locala1);
    }
    return locala;
}
 
Example 20
Project: solo-spring   File: LinkQueryService.java   View Source Code Vote up 3 votes
/**
 * Gets links by the specified request json object.
 *
 * @param requestJSONObject
 *            the specified request json object, for example,
 * 
 *            <pre>
 * {
 *     "paginationCurrentPageNum": 1,
 *     "paginationPageSize": 20,
 *     "paginationWindowSize": 10
 * }, see {@link Pagination} for more details
 *            </pre>
 * 
 * @return for example,
 * 
 *         <pre>
 * {
 *     "pagination": {
 *         "paginationPageCount": 100,
 *         "paginationPageNums": [1, 2, 3, 4, 5]
 *     },
 *     "links": [{
 *         "oId": "",
 *         "linkTitle": "",
 *         "linkAddress": "",
 *         ""linkDescription": ""
 *      }, ....]
 * }
 *         </pre>
 * 
 * @throws ServiceException
 *             service exception
 * @see Pagination
 */
public JSONObject getLinks(final JSONObject requestJSONObject) throws ServiceException {
	final JSONObject ret = new JSONObject();

	try {
		final int currentPageNum = requestJSONObject.getInt(Pagination.PAGINATION_CURRENT_PAGE_NUM);
		final int pageSize = requestJSONObject.getInt(Pagination.PAGINATION_PAGE_SIZE);
		final int windowSize = requestJSONObject.getInt(Pagination.PAGINATION_WINDOW_SIZE);

		final Query query = new Query().setCurrentPageNum(currentPageNum).setPageSize(pageSize)
				.addSort(Link.LINK_ORDER, SortDirection.ASCENDING);
		final JSONObject result = linkDao.get(query);
		final int pageCount = result.getJSONObject(Pagination.PAGINATION).getInt(Pagination.PAGINATION_PAGE_COUNT);

		final JSONObject pagination = new JSONObject();
		final List<Integer> pageNums = Paginator.paginate(currentPageNum, pageSize, pageCount, windowSize);

		pagination.put(Pagination.PAGINATION_PAGE_COUNT, pageCount);
		pagination.put(Pagination.PAGINATION_PAGE_NUMS, pageNums);

		final JSONArray links = result.getJSONArray(Keys.RESULTS);

		ret.put(Pagination.PAGINATION, pagination);
		ret.put(Link.LINKS, links);

		return ret;
	} catch (final Exception e) {
		logger.error("Gets links failed", e);
		throw new ServiceException(e);
	}
}