diff --git a/json-smart/src/main/java/net/minidev/json/parser/JSONParserInputStream.java b/json-smart/src/main/java/net/minidev/json/parser/JSONParserInputStream.java index 77d93e9..b991274 100644 --- a/json-smart/src/main/java/net/minidev/json/parser/JSONParserInputStream.java +++ b/json-smart/src/main/java/net/minidev/json/parser/JSONParserInputStream.java @@ -18,6 +18,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import net.minidev.json.writer.JsonReaderI; @@ -39,7 +40,7 @@ public JSONParserInputStream(int permissiveMode) { * @throws UnsupportedEncodingException */ public Object parse(InputStream in) throws ParseException, UnsupportedEncodingException { - InputStreamReader i2 = new InputStreamReader(in, "utf8"); + InputStreamReader i2 = new InputStreamReader(in, StandardCharsets.UTF_8); return super.parse(i2); } @@ -48,7 +49,7 @@ public Object parse(InputStream in) throws ParseException, UnsupportedEncodingEx * generated by a ContainerFactory */ public T parse(InputStream in, JsonReaderI mapper) throws ParseException, UnsupportedEncodingException { - InputStreamReader i2 = new InputStreamReader(in, "utf8"); + InputStreamReader i2 = new InputStreamReader(in, StandardCharsets.UTF_8); // return super.parse(i2, mapper); } diff --git a/json-smart/src/test/java/net/minidev/json/test/TestUtf8.java b/json-smart/src/test/java/net/minidev/json/test/TestUtf8.java index 9058cbd..234314d 100644 --- a/json-smart/src/test/java/net/minidev/json/test/TestUtf8.java +++ b/json-smart/src/test/java/net/minidev/json/test/TestUtf8.java @@ -2,6 +2,7 @@ import java.io.ByteArrayInputStream; import java.io.StringReader; +import java.nio.charset.StandardCharsets; import java.util.stream.Stream; import net.minidev.json.JSONObject; @@ -47,7 +48,7 @@ public void supportI18nStringReader(String language, String nonLatinText) throws @MethodSource("languages") public void supportI18nByteArrayInputStream(String language, String nonLatinText) throws Exception { String json = "{\"key\":\"" + nonLatinText + "\"}"; - ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes("utf8")); + ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8)); JSONObject obj = (JSONObject) JSONValue.parse(bis); String actual = (String) obj.get("key"); assertEquals(nonLatinText, actual, "Parsing ByteArrayInputStream " + language + " text"); @@ -57,7 +58,7 @@ public void supportI18nByteArrayInputStream(String language, String nonLatinText @MethodSource("languages") public void supportI18nBytes(String language, String nonLatinText) throws Exception { String json = "{\"key\":\"" + nonLatinText + "\"}"; - byte[] bs = json.getBytes("utf8"); + byte[] bs = json.getBytes(StandardCharsets.UTF_8); JSONObject obj = JSONValue.parse(bs, JSONObject.class); String actual = (String) obj.get("key"); assertEquals(nonLatinText, actual, "Parsing bytes[] " + language + " text");