mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[HOTFIX] Фикс десереализации старых byte[].
This commit is contained in:
parent
d6b747ddc1
commit
084b84a6a2
1 changed files with 9 additions and 0 deletions
|
@ -13,6 +13,7 @@
|
||||||
import javax.script.ScriptEngineManager;
|
import javax.script.ScriptEngineManager;
|
||||||
|
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonDeserializationContext;
|
import com.google.gson.JsonDeserializationContext;
|
||||||
import com.google.gson.JsonDeserializer;
|
import com.google.gson.JsonDeserializer;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
|
@ -144,6 +145,14 @@ private static class ByteArrayToBase64TypeAdapter implements JsonSerializer<byte
|
||||||
private Base64.Decoder decoder = Base64.getUrlDecoder();
|
private Base64.Decoder decoder = Base64.getUrlDecoder();
|
||||||
private Base64.Encoder encoder = Base64.getUrlEncoder();
|
private Base64.Encoder encoder = Base64.getUrlEncoder();
|
||||||
public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||||
|
if (json.isJsonArray()) {
|
||||||
|
JsonArray byteArr = json.getAsJsonArray();
|
||||||
|
byte[] arr = new byte[byteArr.size()];
|
||||||
|
for (int i = 0; i < arr.length; i++) {
|
||||||
|
arr[i] = byteArr.get(i).getAsByte();
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
return decoder.decode(json.getAsString());
|
return decoder.decode(json.getAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue