| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8329421 commit 89accda
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | 6 | <groupId>apijson.orm</groupId> | |
| 7 | 7 | <artifactId>apijson-orm</artifactId> | |
| 8 | - <version>5.1.0</version> | ||
| 8 | + <version>5.1.0-F2</version> | ||
| 9 | 9 | <packaging>jar</packaging> | |
| 10 | 10 | ||
| 11 | 11 | <name>APIJSONORM</name> | |
@@ -21,7 +21,7 @@ | |||
| 21 | 21 | <dependency> | |
| 22 | 22 | <groupId>com.alibaba</groupId> | |
| 23 | 23 | <artifactId>fastjson</artifactId> | |
| 24 | - <version>1.2.79</version> | ||
| 24 | + <version>2.0.4</version> | ||
| 25 | 25 | </dependency> | |
| 26 | 26 | <dependency> | |
| 27 | 27 | <groupId>javax.activation</groupId> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -64,18 +64,20 @@ public static String getCorrectJson(String s, boolean isArray) { | |||
| 64 | 64 | * @param json | |
| 65 | 65 | * @return | |
| 66 | 66 | */ | |
| 67 | + private static final Feature[] DEFAULT_FASTJSON_FEATURES = {Feature.OrderedField, Feature.AllowSingleQuotes, Feature.DisableCircularReferenceDetect, Feature.UseBigDecimal, Feature.UseObjectArray}; | ||
| 67 | 68 | public static Object parse(Object obj) { | |
| 68 | 69 | int features = com.alibaba.fastjson.JSON.DEFAULT_PARSER_FEATURE; | |
| 69 | 70 | features |= Feature.OrderedField.getMask(); | |
| 70 | 71 | 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); | ||
| 72 | 73 | } catch (Exception e) { | |
| 73 | 74 | Log.i(TAG, "parse catch \n" + e.getMessage()); | |
| 74 | 75 | } | |
| 75 | 76 | return null; | |
| 76 | 77 | } | |
| 78 | + | ||
| 77 | 79 | /**obj转JSONObject | |
| 78 | - * @param json | ||
| 80 | + * @param obj | ||
| 79 | 81 | * @return | |
| 80 | 82 | */ | |
| 81 | 83 | public static JSONObject parseObject(Object obj) { | |
@@ -89,16 +91,17 @@ public static JSONObject parseObject(Object obj) { | |||
| 89 | 91 | * @return | |
| 90 | 92 | */ | |
| 91 | 93 | 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); | ||
| 95 | 95 | } | |
| 96 | - /**json转JSONObject | ||
| 96 | + | ||
| 97 | + /** | ||
| 98 | + * json转JSONObject | ||
| 99 | + * | ||
| 97 | 100 | * @param json | |
| 98 | 101 | * @param features | |
| 99 | 102 | * @return | |
| 100 | 103 | */ | |
| 101 | - public static JSONObject parseObject(String json, int features) { | ||
| 104 | + public static JSONObject parseObject(String json, Feature... features) { | ||
| 102 | 105 | try { | |
| 103 | 106 | return com.alibaba.fastjson.JSON.parseObject(getCorrectJson(json), JSONObject.class, features); | |
| 104 | 107 | } catch (Exception e) { | |
@@ -127,7 +130,7 @@ public static <T> T parseObject(String json, Class<T> clazz) { | |||
| 127 | 130 | try { | |
| 128 | 131 | int features = com.alibaba.fastjson.JSON.DEFAULT_PARSER_FEATURE; | |
| 129 | 132 | 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); | ||
| 131 | 134 | } catch (Exception e) { | |
| 132 | 135 | Log.i(TAG, "parseObject catch \n" + e.getMessage()); | |
| 133 | 136 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments