本文整理汇总了Java中com.socks.jiandan.net.JSONParser.toObject方法的典型用法代码示例。如果您正苦于以下问题:Java JSONParser.toObject方法的具体用法?Java JSONParser.toObject怎么用?Java JSONParser.toObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.socks.jiandan.net.JSONParser
的用法示例。
在下文中一共展示了JSONParser.toObject方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCacheByPage
import com.socks.jiandan.net.JSONParser; //导入方法依赖的package包/类
/**
* 根据页码获取缓存数据
*
* @param page
* @return
*/
@Override
public ArrayList<Picture> getCacheByPage(int page) {
QueryBuilder<com.socks.greendao.PictureCache> query = mPictureCacheDao.queryBuilder().where(PictureCacheDao
.Properties.Page.eq("" + page));
if (query.list().size() > 0) {
return (ArrayList<Picture>) JSONParser.toObject(query.list().get(0).getResult(),
new TypeToken<ArrayList<Picture>>() {
}.getType());
} else {
return new ArrayList<Picture>();
}
}
示例2: parse
import com.socks.jiandan.net.JSONParser; //导入方法依赖的package包/类
@Nullable
public ArrayList<Joke> parse(Response response) {
code = wrapperCode(response.code());
if (!response.isSuccessful())
return null;
try {
String jsonStr = response.body().string();
jsonStr = new JSONObject(jsonStr).getJSONArray("comments").toString();
return (ArrayList<Joke>) JSONParser.toObject(jsonStr,
new TypeToken<ArrayList<Joke>>() {
}.getType());
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
示例3: parse
import com.socks.jiandan.net.JSONParser; //导入方法依赖的package包/类
@Nullable
public ArrayList<Picture> parse(Response response) {
code = wrapperCode(response.code());
if (!response.isSuccessful())
return null;
try {
String jsonStr = response.body().string();
jsonStr = new JSONObject(jsonStr).getJSONArray("comments").toString();
return (ArrayList<Picture>) JSONParser.toObject(jsonStr,
new TypeToken<ArrayList<Picture>>() {
}.getType());
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
示例4: getCacheByPage
import com.socks.jiandan.net.JSONParser; //导入方法依赖的package包/类
@Override
public ArrayList<Picture> getCacheByPage(int page) {
QueryBuilder<com.socks.greendao.SisterCache> query = mPictureCacheDao.queryBuilder().where(SisterCacheDao
.Properties.Page.eq(Integer.toString(page)));
if (query.list().size() > 0) {
return (ArrayList<Picture>) JSONParser.toObject(query.list().get(0).getResult(),
new TypeToken<ArrayList<Picture>>() {
}.getType());
} else {
return new ArrayList<>();
}
}
示例5: getCacheByPage
import com.socks.jiandan.net.JSONParser; //导入方法依赖的package包/类
@Override
public ArrayList<Video> getCacheByPage(int page) {
QueryBuilder<com.socks.greendao.VideoCache> query = mVideoCacheDao.queryBuilder().where(VideoCacheDao.Properties.Page.eq("" + page));
if (query.list().size() > 0) {
return (ArrayList<Video>) JSONParser.toObject(query.list().get(0).getResult(),
new TypeToken<ArrayList<Video>>() {
}.getType());
} else {
return new ArrayList<>();
}
}
示例6: getCacheByPage
import com.socks.jiandan.net.JSONParser; //导入方法依赖的package包/类
@Override
public ArrayList<Joke> getCacheByPage(int page) {
QueryBuilder<com.socks.greendao.JokeCache> query = mJokeCacheDao.queryBuilder().where(JokeCacheDao.Properties.Page.eq("" + page));
if (query.list().size() > 0) {
return (ArrayList<Joke>) JSONParser.toObject(query.list().get(0).getResult(),
new TypeToken<ArrayList<Joke>>() {
}.getType());
} else {
return new ArrayList<>();
}
}
示例7: parse
import com.socks.jiandan.net.JSONParser; //导入方法依赖的package包/类
@Nullable
public ArrayList<Comment4FreshNews> parse(Response response) {
code = wrapperCode(response.code());
if (!response.isSuccessful())
return null;
try {
String resultStr = response.body().string();
JSONObject resultObj = new JSONObject(resultStr);
String status = resultObj.optString("status");
if (status.equals("ok")) {
String commentsStr = resultObj.optJSONObject("post").optJSONArray("comments")
.toString();
int id = resultObj.optJSONObject("post").optInt("id");
mCallBack.loadFinish(Integer.toString(id));
ArrayList<Comment4FreshNews> comment4FreshNewses = (ArrayList<Comment4FreshNews>) JSONParser.toObject(commentsStr,
new TypeToken<ArrayList<Comment4FreshNews>>() {
}.getType());
Pattern pattern = Pattern.compile("\\d{7}");
for (Comment4FreshNews comment4FreshNews : comment4FreshNewses) {
Matcher matcher = pattern.matcher(comment4FreshNews.getContent());
boolean isHas7Num = matcher.find();
boolean isHasCommentStr = comment4FreshNews.getContent().contains("#comment-");
//有回复
if (isHas7Num && isHasCommentStr || comment4FreshNews.getParentId() != 0) {
ArrayList<Comment4FreshNews> tempComments = new ArrayList<>();
int parentId = getParentId(comment4FreshNews.getContent());
comment4FreshNews.setParentId(parentId);
getParenFreshNews(tempComments, comment4FreshNewses, parentId);
Collections.reverse(tempComments);
comment4FreshNews.setParentComments(tempComments);
comment4FreshNews.setFloorNum(tempComments.size() + 1);
comment4FreshNews.setContent(getContentWithParent(comment4FreshNews.getContent()));
} else {
comment4FreshNews.setContent(getContentOnlySelf(comment4FreshNews.getContent()));
}
}
Logger.d("" + comment4FreshNewses);
return comment4FreshNewses;
} else {
return null;
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
}