Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}

Expand All @@ -48,7 +49,7 @@ public Object parse(InputStream in) throws ParseException, UnsupportedEncodingEx
* generated by a ContainerFactory
*/
public <T> T parse(InputStream in, JsonReaderI<T> mapper) throws ParseException, UnsupportedEncodingException {
InputStreamReader i2 = new InputStreamReader(in, "utf8");
InputStreamReader i2 = new InputStreamReader(in, StandardCharsets.UTF_8);
//
return super.parse(i2, mapper);
}
Expand Down
5 changes: 3 additions & 2 deletions json-smart/src/test/java/net/minidev/json/test/TestUtf8.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand All @@ -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");
Expand Down