问题
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