在java中从XML转换到JSON

时间:2022-10-01 22:18:36
XMLSerializer xmlSerializer = new XMLSerializer(); 
        JSON json  = xmlSerializer.read( xmlString );  
        System.out.println( json.toString(2) );


Exception in thread "main" java.lang.NoClassDefFoundError: nu/xom/Serializer
    at src.main.parser.main(parser.java:19)
Caused by: java.lang.ClassNotFoundException: nu.xom.Serializer
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 1 more

While i am coverting from XML to Json i got this error ...?

当我从XML转换到Json时,我得到了这个错误…?

How can i fix this one .

我怎么才能修好这个。

Thanks Sankar

由于Sankar

2 个解决方案

#1


5  

Download xom jar and add to your class path: http://www.findjar.com/jar/xom/xom/1.0/xom-1.0.jar.html

下载xom jar并添加到您的类路径:http://www.findjar.com/jar/xom/xom/1.0/xom-1.0.jar.html

#2


1  

You need to add the library containing the nu.xom.Serializer class to your classpath.

您需要添加包含nu.xom的库。类路径的序列化器类。

#1


5  

Download xom jar and add to your class path: http://www.findjar.com/jar/xom/xom/1.0/xom-1.0.jar.html

下载xom jar并添加到您的类路径:http://www.findjar.com/jar/xom/xom/1.0/xom-1.0.jar.html

#2


1  

You need to add the library containing the nu.xom.Serializer class to your classpath.

您需要添加包含nu.xom的库。类路径的序列化器类。