use of com.google.gson.reflect.TypeToken in project CloudNet by Dytanic.
the class CloudFlareDatabase method getAndRemove.
public Collection<String> getAndRemove() {
Document document = database.getDocument("cloudflare_cache_dnsrequests");
if (document.contains("requests")) {
Collection<String> responses = document.getObject("requests", new TypeToken<Collection<String>>() {
}.getType());
document.append("requests", new String[0]);
database.insert(document);
return responses;
}
return new ArrayList<>();
}
use of com.google.gson.reflect.TypeToken in project CloudNet by Dytanic.
the class PacketInAddSign method handleInput.
@Override
public void handleInput(Document data, PacketSender packetSender) {
Sign sign = data.getObject("sign", new TypeToken<Sign>() {
}.getType());
SignsModule.getInstance().getSignDatabase().appendSign(sign);
CloudNet.getInstance().getNetworkManager().reload();
CloudNet.getInstance().getNetworkManager().updateAll();
}
use of com.google.gson.reflect.TypeToken in project CloudNet by Dytanic.
the class PacketInAuthReader method handleInput.
@Override
public void handleInput(Document data, PacketSender packetSender) {
Auth auth = data.getObject("auth", new TypeToken<Auth>() {
}.getType());
handleAuth(auth, auth.getType(), auth.getAuthData(), packetSender);
}
use of com.google.gson.reflect.TypeToken in project xDrip by NightscoutFoundation.
the class DisplayQRCode method decodeString.
public static Map<String, String> decodeString(String data) {
try {
if (data.startsWith(qrmarker)) {
data = data.substring(qrmarker.length());
Log.d(TAG, "String to uncompress: " + data);
data = JoH.uncompressString(data);
// Log.d(TAG, "Json after decompression: " + data);
Map<String, String> mymap = new Gson().fromJson(data, new TypeToken<HashMap<String, String>>() {
}.getType());
return mymap;
} else {
Log.e(TAG, "No qrmarker on qrcode");
return null;
}
} catch (Exception e) {
Log.e(TAG, "Got exception during decodingString: " + e.toString());
return null;
}
}
use of com.google.gson.reflect.TypeToken in project Rubicon by Rubicon-Bot.
the class BotlistSpaceClient method getBots.
public List<Bot> getBots() throws IOException {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url("https://botlist.space/api/bots").build();
Response response = client.newCall(request).execute();
List<Bot> gson = new Gson().fromJson(response.body().string(), new TypeToken<List<Bot>>() {
}.getType());
response.close();
return gson;
}
Aggregations