try catch内层嵌套try catch时内层catch捕获到异常,然后需要执行操作

//通过传入需要的数据的key。去将key对应的value转换为jsonObject类型的数据;
//前提是返回的数据的key不能重复,不然只会得到最后一层key的value;
public JSONObject conventJsonObjectByKey(String key,JSONObject jsonObject){
JSONObject returnJsonObject=null;
boolean flag=false;
if(jsonObject!=null) {
for (Map.Entry entry : jsonObject.entrySet()) {
if (entry.getKey().equals(key)) {
System.out.println("key"+key);
flag = true;
if (entry.getValue() != null) {
try{
System.out.println("entry.getValue()"+entry.getValue());
returnJsonObject = JSON.parseObject(entry.getValue().toString());
}catch (ClassCastException e){
System.out.println("entry.getKey()"+entry.getKey());
System.out.println("entry.getValue()"+entry.getValue());
returnJsonObject.put(entry.getKey(),entry.getValue());
}
}
else {
returnJsonObject.put(entry.getKey(),"");
}
}
}
if (flag == false) {
for (Map.Entry entry : jsonObject.entrySet()) {
JSONObject valueJsonObject = null;
try {
valueJsonObject = JSON.parseObject(entry.getValue().toString());
System.out.println("value"+entry.getValue());
System.out.println("valueObject"+valueJsonObject);
conventJsonObjectByKey(key, valueJsonObject);
} catch (Exception e) {
System.out.println("err"+entry.getValue());
}
}
}
}
return returnJsonObject;
}

不知道你说的是什么意思,两层嵌套try catch就是了。