77 * Created by webee on 16/11/25.
88 */
99public final class Utils {
10+ /**
11+ * judge value's json type.
12+ * @param value the value to judge.
13+ * @return the json type.
14+ */
1015 public static JSONType getType (Object value ) {
1116 if (value == null ) {
1217 return JSONType .Null ;
@@ -22,10 +27,19 @@ public static JSONType getType(Object value) {
2227 return JSONType .Object ;
2328 } else if (value instanceof Object []) {
2429 return JSONType .Array ;
30+ } else if (value instanceof JSONObject ) {
31+ return JSONType .Object ;
32+ } else if (value instanceof JSONArray ) {
33+ return JSONType .Array ;
2534 }
2635 return null ;
2736 }
2837
38+ /**
39+ * convert JSONArray to a Object[] array mixed tree with pure java objects.
40+ * @param array the JSONArray to convert.
41+ * @return the pure java objects array mixed tree.
42+ */
2943 public static Object [] arrayToObjects (JSONArray array ) {
3044 if (array == null ) {
3145 return null ;
@@ -38,6 +52,11 @@ public static Object[] arrayToObjects(JSONArray array) {
3852 return res ;
3953 }
4054
55+ /**
56+ * convert JSONObject to a Map<String, Object> tree with pure java objects.
57+ * @param object the JSONObject to convert.
58+ * @return the pure java objects tree .
59+ */
4160 public static Map <String , Object > objectToMap (JSONObject object ) {
4261 if (object == null ) {
4362 return null ;
@@ -50,6 +69,11 @@ public static Map<String, Object> objectToMap(JSONObject object) {
5069 return res ;
5170 }
5271
72+ /**
73+ * convert value to pure java objects.
74+ * @param value the value to convert.
75+ * @return pure java object.
76+ */
5377 public static Object resolveValue (Object value ) {
5478 if (value instanceof JSONArray ) {
5579 return Utils .arrayToObjects ((JSONArray ) value );
0 commit comments