Skip to content

Commit 89accda

Browse files
committed
fastjson up2 2.0.4
1 parent 8329421 commit 89accda

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

APIJSONORM/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>apijson.orm</groupId>
77
<artifactId>apijson-orm</artifactId>
8-
<version>5.1.0</version>
8+
<version>5.1.0-F2</version>
99
<packaging>jar</packaging>
1010

1111
<name>APIJSONORM</name>
@@ -21,7 +21,7 @@
2121
<dependency>
2222
<groupId>com.alibaba</groupId>
2323
<artifactId>fastjson</artifactId>
24-
<version>1.2.79</version>
24+
<version>2.0.4</version>
2525
</dependency>
2626
<dependency>
2727
<groupId>javax.activation</groupId>

APIJSONORM/src/main/java/apijson/JSON.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,20 @@ public static String getCorrectJson(String s, boolean isArray) {
6464
* @param json
6565
* @return
6666
*/
67+
private static final Feature[] DEFAULT_FASTJSON_FEATURES = {Feature.OrderedField, Feature.AllowSingleQuotes, Feature.DisableCircularReferenceDetect, Feature.UseBigDecimal, Feature.UseObjectArray};
6768
public static Object parse(Object obj) {
6869
int features = com.alibaba.fastjson.JSON.DEFAULT_PARSER_FEATURE;
6970
features |= Feature.OrderedField.getMask();
7071
try {
71-
return com.alibaba.fastjson.JSON.parse(obj instanceof String ? (String) obj : toJSONString(obj), features);
72+
return com.alibaba.fastjson.JSON.parse(obj instanceof String ? (String) obj : toJSONString(obj), DEFAULT_FASTJSON_FEATURES);
7273
} catch (Exception e) {
7374
Log.i(TAG, "parse catch \n" + e.getMessage());
7475
}
7576
return null;
7677
}
78+
7779
/**obj转JSONObject
78-
* @param json
80+
* @param obj
7981
* @return
8082
*/
8183
public static JSONObject parseObject(Object obj) {
@@ -89,16 +91,17 @@ public static JSONObject parseObject(Object obj) {
8991
* @return
9092
*/
9193
public static JSONObject parseObject(String json) {
92-
int features = com.alibaba.fastjson.JSON.DEFAULT_PARSER_FEATURE;
93-
features |= Feature.OrderedField.getMask();
94-
return parseObject(json, features);
94+
return parseObject(json, DEFAULT_FASTJSON_FEATURES);
9595
}
96-
/**json转JSONObject
96+
97+
/**
98+
* json转JSONObject
99+
*
97100
* @param json
98101
* @param features
99102
* @return
100103
*/
101-
public static JSONObject parseObject(String json, int features) {
104+
public static JSONObject parseObject(String json, Feature... features) {
102105
try {
103106
return com.alibaba.fastjson.JSON.parseObject(getCorrectJson(json), JSONObject.class, features);
104107
} catch (Exception e) {
@@ -127,7 +130,7 @@ public static <T> T parseObject(String json, Class<T> clazz) {
127130
try {
128131
int features = com.alibaba.fastjson.JSON.DEFAULT_PARSER_FEATURE;
129132
features |= Feature.OrderedField.getMask();
130-
return com.alibaba.fastjson.JSON.parseObject(getCorrectJson(json), clazz, features);
133+
return com.alibaba.fastjson.JSON.parseObject(getCorrectJson(json), clazz, DEFAULT_FASTJSON_FEATURES);
131134
} catch (Exception e) {
132135
Log.i(TAG, "parseObject catch \n" + e.getMessage());
133136
}

0 commit comments

Comments
 (0)