JSONObject jso = (JSONObject) o;
String java_class;
try {
java_class = jso.getString(TAG_JAVACLASS);
} catch (JSONException e) {
throw new UnmarshallException("Could not read javaClass", e);
}
if (java_class == null) {
throw new UnmarshallException("no type hint");
}
if (!(java_class.equals("java.util.Map") ||
java_class.equals("java.util.AbstractMap") ||
java_class.equals("java.util.LinkedHashMap") ||
java_class.equals("java.util.TreeMap") ||
java_class.equals("java.util.HashMap"))) {
throw new UnmarshallException("'" + java_class + "' is not a Map");
}
JSONObject jsonmap;
try {
jsonmap = jso.getJSONObject("map");
} catch (JSONException e) {
throw new UnmarshallException("Could not read map: " + e.getMessage(), e);
}
if (jsonmap == null) {
throw new UnmarshallException("map missing");
}
ObjectMatch m = new ObjectMatch(-1);
Iterator i = jsonmap.keys();
String key = null;
state.setSerialized(o, m);
try {
while (i.hasNext()) {
key = (String) i.next();
m.setMismatch(_ser.tryUnmarshall(state, null, jsonmap.get(key)).max(m).getMismatch());
}
} catch (UnmarshallException e) {
throw new UnmarshallException("key " + key + " " + e.getMessage(), e);
} catch (JSONException e) {
throw new UnmarshallException("key " + key + " " + e.getMessage(), e);
}
return m;
}