I've downloaded and added a json-simple.jar
to my project in eclipse. The only problem is with the Parser, Eclipse says "parser cannot be resolved"
. While the JSONObject
and JSONArray
are working just fine.
I get the error when trying to read the file :
JSONParser parser = new JSONParser();
JSONArray jArray = (JSONArray) parser.parse(new FileReader("comments.json"));
imported as follows :
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
I've just started using json, so i might be missing something.
The comments.json
file is of this format :
{
"postId": 1,
"id": 1,
"name": "id labore ex et quam laborum",
"email": "Eliseo@gardner.biz",
"body": "laudantium enim quasi est"
}