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:
1515 maven { url "https://jitpack.io" }
1616 }
1717 dependencies {
18- compile 'com.github.webee:java-json-api:v2.0 .0'
18+ compile 'com.github.webee:java-json-api:v2.1 .0'
1919 }
2020 ```
Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ public static JSONType getType(Object value) {
2727 return JSONType .Object ;
2828 } else if (value instanceof JSONArray ) {
2929 return JSONType .Array ;
30+ } else if (value instanceof Map ) {
31+ return JSONType .Object ;
32+ } else if (value instanceof Object []) {
33+ return JSONType .Array ;
3034 }
3135 return null ;
3236 }
@@ -99,24 +103,29 @@ public static Object resolveValue(Object value) {
99103 }
100104
101105 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 ;
107126 }
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 ;
120127 }
128+ // FIXME: some type should be ignored.
129+ return null ;
121130 }
122131}
You can’t perform that action at this time.
0 commit comments