Example usage for org.json JSONObject optBoolean

List of usage examples for org.json JSONObject optBoolean

Introduction

In this page you can find the example usage for org.json JSONObject optBoolean.

Prototype

public boolean optBoolean(String key, boolean defaultValue) 

Source Link

Document

Get an optional boolean associated with a key.

Usage

From source file:com.danlvse.weebo.model.User.java

public static User parse(JSONObject jsonObject) {
    if (null == jsonObject) {
        return null;
    }//from  w  w w.j a va  2 s .c o  m

    User user = new User();
    user.id = jsonObject.optString("id", "");
    user.idstr = jsonObject.optString("idstr", "");
    user.screen_name = jsonObject.optString("screen_name", "");
    user.name = jsonObject.optString("name", "");
    user.province = jsonObject.optInt("province", -1);
    user.city = jsonObject.optInt("city", -1);
    user.location = jsonObject.optString("location", "");
    user.description = jsonObject.optString("description", "");
    user.url = jsonObject.optString("url", "");
    user.profile_image_url = jsonObject.optString("profile_image_url", "");
    user.profile_url = jsonObject.optString("profile_url", "");
    user.cover_image_phone = jsonObject.optString("cover_image_phone", "");
    user.cover_image = jsonObject.optString("cover_image", "");
    user.domain = jsonObject.optString("domain", "");
    user.weihao = jsonObject.optString("weihao", "");
    user.gender = jsonObject.optString("gender", "");
    user.followers_count = jsonObject.optInt("followers_count", 0);
    user.friends_count = jsonObject.optInt("friends_count", 0);
    user.statuses_count = jsonObject.optInt("statuses_count", 0);
    user.favourites_count = jsonObject.optInt("favourites_count", 0);
    user.created_at = jsonObject.optString("created_at", "");
    user.following = jsonObject.optBoolean("following", false);
    user.allow_all_act_msg = jsonObject.optBoolean("allow_all_act_msg", false);
    user.geo_enabled = jsonObject.optBoolean("geo_enabled", false);
    user.verified = jsonObject.optBoolean("verified", false);
    user.verified_type = jsonObject.optInt("verified_type", -1);
    user.remark = jsonObject.optString("remark", "");
    user.status = Feed.parse(jsonObject.optJSONObject("status"));
    user.allow_all_comment = jsonObject.optBoolean("allow_all_comment", true);
    user.avatar_large = jsonObject.optString("avatar_large", "");
    user.avatar_hd = jsonObject.optString("avatar_hd", "");
    user.verified_reason = jsonObject.optString("verified_reason", "");
    user.follow_me = jsonObject.optBoolean("follow_me", false);
    user.online_status = jsonObject.optInt("online_status", 0);
    user.bi_followers_count = jsonObject.optInt("bi_followers_count", 0);
    user.lang = jsonObject.optString("lang", "");

    user.star = jsonObject.optString("star", "");
    user.mbtype = jsonObject.optString("mbtype", "");
    user.mbrank = jsonObject.optString("mbrank", "");
    user.block_word = jsonObject.optString("block_word", "");

    return user;
}