use of com.jcabi.http.response.JsonResponse in project jcabi-github by jcabi.
the class RtUser method notifications.
@Override
public List<Notification> notifications() throws IOException {
final List<Notification> list = new LinkedList<Notification>();
final JsonResponse resp = this.github().entry().uri().path("notifications").back().fetch().as(JsonResponse.class);
final JsonArray array = resp.json().readArray();
for (final JsonValue value : array) {
final JsonObject notif = (JsonObject) value;
list.add(this.createNotification(notif));
}
return list;
}
use of com.jcabi.http.response.JsonResponse in project jcabi-github by jcabi.
the class Main method main.
/**
* Main entry point.
* @param args Command line arguments
*/
public static void main(final String[] args) throws Exception {
final Github github = new RtGithub();
final JsonResponse resp = github.entry().uri().path("/search/repositories").queryParam("q", "java").back().fetch().as(JsonResponse.class);
final List<JsonObject> items = resp.json().readObject().getJsonArray("items").getValuesAs(JsonObject.class);
for (final JsonObject item : items) {
System.out.println(String.format("repository found: %s", item.get("full_name").toString()));
}
}
use of com.jcabi.http.response.JsonResponse in project jcabi-github by jcabi.
the class RtSearchTest method readNonUnicode.
/**
* RtSearch can read non-unicode.
* @throws Exception if any problem inside
*/
@Test
public void readNonUnicode() throws Exception {
final Response resp = new FakeRequest().withBody("{\"help\": \"\u001Fblah\u0001cwhoa\u0000!\"}").fetch();
final JsonResponse response = new JsonResponse(resp);
MatcherAssert.assertThat(response.json().readObject().getString("help"), Matchers.is("\u001Fblah\u0001cwhoa\u0000!"));
}
Aggregations