Decode JSON with Java

本秂侑毒 提交于 2020-01-06 13:28:46

问题


I am trying to decode JSON data with Java. I found a library at the following link: http://code.google.com/p/json-simple/wiki/DecodingExamples

I have included the .jar file in the build path in my eclipse project, which added the library under "Referenced Libraries". But when I try to use the library as shown in the first example in the link above, the type is not found.

String s="[0,{\"1\":{\"2\":{\"3\":{\"4\":[5,{\"6\":7}]}}}}]";
Object obj=JSONValue.parse(s);
// Error: JSONValue cannot be resolved

I know this question may be a bit naive, but can someone point out what step I am doing wrong?

The list of imports so far are:

import java.io.DataInputStream;
import java.io.DataOutputStream;    
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import org.json.JSONException;
import org.json.JSONStringer;

Thanks.


回答1:


I think you have downloaded json-simple-1.1-bundle.jar, instead, you should download the fourth one:json_simple-1.1.jar




回答2:


Did you... forget to import it?



来源:https://stackoverflow.com/questions/8264267/decode-json-with-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!