Back to project page ReadabilitySDK.
The source code is released under:
MIT License
If you think the Android project ReadabilitySDK listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.idemidov.readability.parser; //w w w .j av a 2 s . c o m import com.idemidov.readability.data.Article; import com.idemidov.readability.data.CommandResponse; import com.idemidov.readability.util.ResultCode; import org.json.JSONException; import org.json.JSONObject; /** * Created by Ilya on 01/03/14. */ public class GetArticleByIdParser implements Parser<Article> { @Override public CommandResponse<Article> parse(String response) throws JSONException { CommandResponse<Article> result = new CommandResponse<Article>(); result.setData(parseArticle(new JSONObject(response))); result.setCode(ResultCode.CODE_OK); return result; } public static Article parseArticle(JSONObject jsonArticle) { Article article = new Article(); article.setDirection(jsonArticle.optString("direction")); article.setNextPageHref(jsonArticle.optString("next_page_href")); article.setAuthor(jsonArticle.optString("author")); article.setUrl(jsonArticle.optString("url")); article.setLeadImageUrl(jsonArticle.optString("lead_image_url")); article.setTitle(jsonArticle.optString("title")); article.setExcerpt(jsonArticle.optString("excerpt")); article.setDomain(jsonArticle.optString("domain")); article.setWordCount(jsonArticle.optInt("word_count")); article.setContent(jsonArticle.optString("content")); article.setDatePublished(jsonArticle.optString("date_published")); article.setDek(jsonArticle.optString("dek")); article.setProcessed(jsonArticle.optBoolean("processed")); article.setContentSize(jsonArticle.optInt("content_size")); article.setShortUrl(jsonArticle.optString("short_url")); article.setId(jsonArticle.optString("id")); return article; } }