File tree Expand file tree Collapse file tree 2 files changed +27
-18
lines changed
src/main/java/com/github/webee/json Expand file tree Collapse file tree 2 files changed +27
-18
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,6 @@ To install the library add:
15
15
maven { url "https://jitpack.io" }
16
16
}
17
17
dependencies {
18
- compile 'com.github.webee:java-json-api:v2.0 .0'
18
+ compile 'com.github.webee:java-json-api:v2.1 .0'
19
19
}
20
20
```
Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ public static JSONType getType(Object value) {
27
27
return JSONType .Object ;
28
28
} else if (value instanceof JSONArray ) {
29
29
return JSONType .Array ;
30
+ } else if (value instanceof Map ) {
31
+ return JSONType .Object ;
32
+ } else if (value instanceof Object []) {
33
+ return JSONType .Array ;
30
34
}
31
35
return null ;
32
36
}
@@ -99,24 +103,29 @@ public static Object resolveValue(Object value) {
99
103
}
100
104
101
105
public static Object resolveValue (Object value , JSONType t ) {
102
- if (t == null ) {
103
- if (value instanceof Map ) {
104
- return Utils .objectToMap ((Map <String , Object >) value );
105
- } else if (value instanceof Object []) {
106
- return Utils .arrayToObjects ((Object []) value );
106
+ if (t != null ) {
107
+ switch (t ) {
108
+ case Object :
109
+ if (value instanceof JSONObject ) {
110
+ return Utils .objectToMap ((JSONObject ) value );
111
+ } else if (value instanceof Map ) {
112
+ return Utils .objectToMap ((Map <String , Object >) value );
113
+ }
114
+ break ;
115
+ case Array :
116
+ if (value instanceof JSONArray ) {
117
+ return Utils .arrayToObjects ((JSONArray ) value );
118
+ } else if (value instanceof Object []) {
119
+ return Utils .arrayToObjects ((Object []) value );
120
+ }
121
+ break ;
122
+ case Null :
123
+ return null ;
124
+ default :
125
+ return value ;
107
126
}
108
- return null ;
109
- }
110
-
111
- switch (t ) {
112
- case Object :
113
- return Utils .objectToMap ((JSONObject ) value );
114
- case Array :
115
- return Utils .arrayToObjects ((JSONArray ) value );
116
- case Null :
117
- return null ;
118
- default :
119
- return value ;
120
127
}
128
+ // FIXME: some type should be ignored.
129
+ return null ;
121
130
}
122
131
}
You can’t perform that action at this time.
0 commit comments