mirror of
https://github.com/alibaba/fastjson.git
synced 2026-10-28 22:04:04 +08:00
fixed compatible with JDK 5
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
package com.alibaba.fastjson;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Type;
|
||||
@@ -112,7 +113,11 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
}
|
||||
|
||||
public static final Object parse(byte[] input, Feature... features) {
|
||||
return parseObject(new String(input, Charset.forName("UTF-8")), features);
|
||||
try {
|
||||
return parseObject(new String(input, "UTF-8"), features);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new JSONException("UTF-8 not support");
|
||||
}
|
||||
}
|
||||
|
||||
public static final Object parse(String text, Feature... features) {
|
||||
@@ -224,7 +229,11 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final <T> T parseObject(byte[] input, Type clazz, Feature... features) {
|
||||
return (T) parseObject(new String(input, Charset.forName("UTF-8")), clazz, features);
|
||||
try {
|
||||
return (T) parseObject(new String(input, "UTF-8"), clazz, features);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new JSONException("UTF-8 not support");
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
Reference in New Issue
Block a user