json数据JS处理起来蛮方便,java处理起来的话我是用导入的Json-lib这个包,源码写好了,执行时总是报如下错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:620) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$000(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
几经检查,程序没问题,原来是myeclipse的lib包有问题,主要是json-lib的dependencies 包缺少,依赖包一共如下几个,全部包含的话,OK搞定!(http://json-lib.sourceforge.net/)
Json-lib requires (at least) the following dependencies in your classpath:
- jakarta commons-lang 2.4
- jakarta commons-beanutils 1.7.0
- jakarta commons-collections 3.2
- jakarta commons-logging 1.1.1
- ezmorph 1.0.6
楼主该用maven了
[Reply]
JSON盲表示忽然觉得鸭梨好大 ~
[Reply]
久酷
Reply:
September 5th, 2010 at 00:48
@小邪, JSON用起来非常方便^_^ 不过也很简单,以小邪的能力,看一遍就可以搞定了,哈哈
[Reply]
呵呵,貌似我毕业设计的网站就是用部分JSON的格式做传输,这个比较方便。而且因为是JavaScript很好写这种格式。当初用Ext,jquery的时候,都习惯用JSON格式了。但是后台来写JSON格,就不是很利索,有些长。。
往事啊。。又被你提起了
[Reply]
久酷
Reply:
September 5th, 2010 at 00:48
@YY船长, JSON 确实非常方便 ,HOHO
[Reply]
久酷
Reply:
September 5th, 2010 at 00:48
@YY船长, 我发现你还在用IE6 HOHO
[Reply]
YY船长
Reply:
September 5th, 2010 at 20:01
@久酷, IE7或者Chrome。。。
[Reply]
の没见过这个错误…
[Reply]
发现你是全才呀,什么都厉害。
[Reply]
久酷
Reply:
September 3rd, 2010 at 11:13
@股票入门基础知识, 略懂、略懂,哈哈
[Reply]
[...] This post was mentioned on Twitter by Jiucool, 热点风向标. 热点风向标 said: Java处理JSON数据错误解决办法 http://ff.im/-q6XZS [...]
沙发!然后去洗白白鸟,今天双沙发!
[Reply]
久酷
Reply:
September 2nd, 2010 at 23:14
@zwwooooo, 哈哈,我这里人气没你旺,很容易滴
[Reply]
BoKeam
Reply:
September 3rd, 2010 at 08:37
@久酷, 你这太专业了,有的时候都不知道怎么留言
[Reply]
久酷
Reply:
September 3rd, 2010 at 09:14
@BoKeam, 呃呃……等你需要用的时候就有帮助啦