0

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.

Programmer Bruce
  • 64,977
  • 7
  • 99
  • 97
Jake
  • 16,329
  • 50
  • 126
  • 202

2 Answers2

2

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

soulmachine
  • 3,917
  • 4
  • 46
  • 56
0

Did you... forget to import it?

Matti Virkkunen
  • 63,558
  • 9
  • 127
  • 159
  • I tried using Ctrl+Shift+O in eclipse but I guess the necessary imports were not added. – Jake Nov 25 '11 at 02:33
  • @Jake: Did you properly reference the library? Also edit your question and add the exact error message. – Matti Virkkunen Nov 25 '11 at 02:33
  • I can see the library in the "Referenced libraries" section in my eclipse project folder hierarchy. – Jake Nov 25 '11 at 02:36
  • @Jake: Could you take a look at the imports yourself and see if it was properly imported? If you're unsure, could you paste all the imports in the question. – Matti Virkkunen Nov 25 '11 at 02:38