From 595775d273a6af92268426e9f66e39082e389aa9 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 28 Nov 2016 15:25:11 +0300 Subject: fix vk users.get deserialization --- .../src/main/java/com/juick/www/VKontakteLogin.java | 2 +- .../main/java/com/juick/www/vk/GraphResponse.java | 19 ------------------- .../main/java/com/juick/www/vk/UsersResponse.java | 21 +++++++++++++++++++++ 3 files changed, 22 insertions(+), 20 deletions(-) delete mode 100644 juick-www/src/main/java/com/juick/www/vk/GraphResponse.java create mode 100644 juick-www/src/main/java/com/juick/www/vk/UsersResponse.java (limited to 'juick-www') diff --git a/juick-www/src/main/java/com/juick/www/VKontakteLogin.java b/juick-www/src/main/java/com/juick/www/VKontakteLogin.java index 1ccf36b6..55dfd202 100644 --- a/juick-www/src/main/java/com/juick/www/VKontakteLogin.java +++ b/juick-www/src/main/java/com/juick/www/VKontakteLogin.java @@ -88,7 +88,7 @@ public class VKontakteLogin { } try { - com.juick.www.vk.User jsonUser = mapper.readValue(graph, GraphResponse.class).getUser(); + com.juick.www.vk.User jsonUser = mapper.readValue(graph, UsersResponse.class).getUsers().get(0); String vkName = jsonUser.getFirstName() + " " + jsonUser.getLastName(); String vkLink = jsonUser.getScreenName(); diff --git a/juick-www/src/main/java/com/juick/www/vk/GraphResponse.java b/juick-www/src/main/java/com/juick/www/vk/GraphResponse.java deleted file mode 100644 index f1985a91..00000000 --- a/juick-www/src/main/java/com/juick/www/vk/GraphResponse.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.juick.www.vk; - -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Created by vitalyster on 28.11.2016. - */ -public class GraphResponse { - private User user; - - @JsonValue - public User getUser() { - return user; - } - - public void setUser(User user) { - this.user = user; - } -} diff --git a/juick-www/src/main/java/com/juick/www/vk/UsersResponse.java b/juick-www/src/main/java/com/juick/www/vk/UsersResponse.java new file mode 100644 index 00000000..d77aa481 --- /dev/null +++ b/juick-www/src/main/java/com/juick/www/vk/UsersResponse.java @@ -0,0 +1,21 @@ +package com.juick.www.vk; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +/** + * Created by vitalyster on 28.11.2016. + */ +public class UsersResponse { + private List users; + + @JsonProperty("response") + public List getUsers() { + return users; + } + + public void setUsers(List users) { + this.users = users; + } +} -- cgit v1.2.3