Java Code Examples for javax.json.JsonException#getMessage()
The following examples show how to use
javax.json.JsonException#getMessage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WeiboUser.java From albert with MIT License | 5 votes |
private void init(JsonObject json) throws WeiboException { if (json != null) { try { id = json.getJsonNumber("id").longValue(); screenName = json.getString("screen_name"); name = json.getString("name"); province = Integer.parseInt(json.getString("province")); city = Integer.parseInt(json.getString("city")); location = json.getString("location"); description = WeiboResponseUtil.withNonBmpStripped(json.getString("description")); url = json.getString("url"); profileImageUrl = json.getString("profile_image_url"); domain = json.getString("domain"); gender = json.getString("gender"); followersCount = json.getInt("followers_count"); friendsCount = json.getInt("friends_count"); favouritesCount = json.getInt("favourites_count"); statusesCount = json.getInt("statuses_count"); createdAt = WeiboResponseUtil.parseDate(json.getString("created_at"), "EEE MMM dd HH:mm:ss z yyyy"); following = json.getBoolean("following"); verified = json.getBoolean("verified"); verifiedType = json.getInt("verified_type"); verifiedReason = json.getString("verified_reason"); allowAllActMsg = json.getBoolean("allow_all_act_msg"); allowAllComment = json.getBoolean("allow_all_comment"); followMe = json.getBoolean("follow_me"); avatarLarge = json.getString("avatar_large"); onlineStatus = json.getInt("online_status"); biFollowersCount = json.getInt("bi_followers_count"); if (!json.getString("remark").isEmpty()) { remark = json.getString("remark"); } lang = json.getString("lang"); weihao = json.getString("weihao"); } catch (JsonException jsone) { throw new WeiboException(jsone.getMessage() + ":" + json.toString(), jsone); } } }
Example 2
Source File: WeiboUser.java From albert with MIT License | 5 votes |
public static String[] constructIds(JsonObject res) throws WeiboException { try { JsonArray list = res.getJsonArray("ids"); String temp = list.toString().substring(1, list.toString().length() - 1); String[] ids = temp.split(","); return ids; } catch (JsonException jsone) { throw new WeiboException(jsone.getMessage() + ":" + jsone.toString(), jsone); } }
Example 3
Source File: AdminServlet.java From sample.microservices.12factorapp with Apache License 2.0 | 5 votes |
private String parse(String stats) throws IOException { // Convert string to jsonObject InputStream is = new ByteArrayInputStream(stats.getBytes("UTF-8")); JsonReader reader = Json.createReader(is); String output = ""; try { JsonArray jsonArray = reader.readArray(); JsonObject jsonObject = jsonArray.getJsonObject(0); JsonObject topLevelValue = (JsonObject) jsonObject.get("value"); JsonObject value = (JsonObject) topLevelValue.get("value"); JsonValue currentValue = value.get("currentValue"); JsonValue desc = value.get("description"); output = "Stats:" + desc.toString() + ": " + currentValue.toString(); } catch (JsonException e) { reader.close(); is.close(); if (e.getMessage().equals("Cannot read JSON array, found JSON object")) { output = "MXBean not created yet, the application must be accessed at least " + "once to get statistics"; } else { output = "A JSON Exception occurred: " + e.getMessage(); } } reader.close(); is.close(); return output; }
Example 4
Source File: WeiboStatus.java From albert with MIT License | 4 votes |
private void constructJson(JsonObject json) throws WeiboException { try { createdAt = WeiboResponseUtil.parseDate(json.getString("created_at"), "EEE MMM dd HH:mm:ss z yyyy"); id = json.getJsonNumber("id").longValue(); mid = json.getString("mid"); idstr = json.getString("idstr"); text = WeiboResponseUtil.withNonBmpStripped(json.getString("text")); if (!json.getString("source").isEmpty()) { source = new Source(WeiboResponseUtil.withNonBmpStripped(json.getString("source"))); } inReplyToStatusId = json.getString("in_reply_to_status_id"); inReplyToUserId = json.getString("in_reply_to_user_id"); inReplyToScreenName = json.getString("in_reply_to_screen_name"); favorited = json.getBoolean("favorited"); truncated = json.getBoolean("truncated"); thumbnailPic = JsonUtil.getString(json, "thumbnail_pic"); bmiddlePic = JsonUtil.getString(json, "bmiddle_pic"); originalPic = JsonUtil.getString(json, "original_pic"); repostsCount = json.getInt("reposts_count"); commentsCount = json.getInt("comments_count"); if (json.containsKey("annotations")) annotations = json.getJsonArray("annotations").toString(); if (!json.isNull("user")) weiboUser = new WeiboUser(json.getJsonObject("user")); if (json.containsKey("retweeted_status")) { retweetedStatus = new WeiboStatus(json.getJsonObject("retweeted_status")); } mlevel = json.getInt("mlevel"); if (json.isNull("geo")) { geo = null; } else { geo = json.getJsonObject("geo").toString(); } if (geo != null && !"".equals(geo) && !"null".equals(geo)) { getGeoInfo(geo); } if (!json.isNull("visible")) { visible = new Visible(json.getJsonObject("visible")); } } catch (JsonException je) { throw new WeiboException(je.getMessage() + ":" + json.toString(), je); } }