工作中遇到下面代码在将String字符串转换成JSONObject类型的时候抛出NestableRuntimeException异常
JSONObject jsonResult = JSONObject.fromObject(str);
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException
很有可能json包版本出现了问题,比如你使用的是commons-lang-3.1以上的版本,就会出现上面的错误,
我是将commons-lang-3.1版本换成了2.6版本之后就没问题
使用json需要导入的包为: