Merge pull request #118 from Slarper/main

fixed potential decoding bug.
This commit is contained in:
paulevsGitch 2022-03-26 03:45:28 +03:00 committed by GitHub
commit 57fdcafb6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,6 +22,7 @@ import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.Reader; import java.io.Reader;
import java.nio.charset.StandardCharsets;
public class JsonFactory { public class JsonFactory {
public final static Gson GSON = new GsonBuilder().setPrettyPrinting() public final static Gson GSON = new GsonBuilder().setPrettyPrinting()
@ -69,7 +70,7 @@ public class JsonFactory {
Resource resource = manager.getResource(location); Resource resource = manager.getResource(location);
if (resource != null) { if (resource != null) {
InputStream stream = resource.getInputStream(); InputStream stream = resource.getInputStream();
InputStreamReader reader = new InputStreamReader(stream); InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8);
obj = JsonFactory.GSON.fromJson(reader, JsonObject.class); obj = JsonFactory.GSON.fromJson(reader, JsonObject.class);
reader.close(); reader.close();
stream.close(); stream.close();