From 3b1897f083efa81e9b8c8d0f404282b1188712ef Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Mon, 12 Dec 2016 17:54:12 -0500 Subject: [PATCH] Fixing bug in GetAccountNameById --- .../graphenej/api/GetAccountNameById.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountNameById.java b/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountNameById.java index e7f465a..f15e441 100644 --- a/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountNameById.java +++ b/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountNameById.java @@ -1,9 +1,11 @@ package de.bitsharesmunich.graphenej.api; -import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; +import de.bitsharesmunich.graphenej.AccountOptions; +import de.bitsharesmunich.graphenej.Authority; import de.bitsharesmunich.graphenej.RPC; import de.bitsharesmunich.graphenej.interfaces.JsonSerializable; import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener; @@ -60,10 +62,12 @@ public class GetAccountNameById extends WebSocketAdapter { public void onTextFrame(WebSocket websocket, WebSocketFrame frame) throws Exception { System.out.println("<<< "+frame.getPayloadText()); String response = frame.getPayloadText(); - Gson gson = new Gson(); + GsonBuilder builder = new GsonBuilder(); Type GetAccountByAddressResponse = new TypeToken>>() {}.getType(); - WitnessResponse>> witnessResponse = gson.fromJson(response, GetAccountByAddressResponse); + builder.registerTypeAdapter(Authority.class, new Authority.AuthorityDeserializer()); + builder.registerTypeAdapter(AccountOptions.class, new AccountOptions.AccountOptionsDeserializer()); + WitnessResponse> witnessResponse = builder.create().fromJson(response, GetAccountByAddressResponse); if (witnessResponse.error != null) { this.mListener.onError(witnessResponse.error);