@Override public CurrentTopic get() throws Exception { try { String json = client.getStringContent(topicRequestUrl(serverUrl)); return parseResponseJson(json); } catch (NoContentException ex) { return CurrentTopic.empty(); } }
private CurrentTopic parseResponseJson(String json) { try { JSONObject obj = new JSONObject(json); String id = obj.getString("id"); String text = obj.getString("text"); return CurrentTopic.create(id, text); } catch (JSONException e) { throw new RuntimeException(e); } }