@@ -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