I would like to parse a json file, here is my code:
import org.json.JSONArray;
import org.json.JSONObject;
public class principale {
public static void main(String[] args) {
// TODO Auto-generated method stub
String fichier ="C:\\listesanscoord.json";
JSONObject obj = new JSONObject("fichier");
String pageName = obj.getJSONObject("pageInfo").getString("pageName");
JSONArray arr = obj.getJSONArray("oaci");
for (int i = 0; i < arr.length(); i++)
{
String url = arr.getJSONObject(i).getString("url");
}
}
}
and here is my json file: listesanscoord.json I have the following error:
Exception in thread "main" org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
at org.json.JSONTokener.syntaxError(JSONTokener.java:433)
at org.json.JSONObject.<init>(JSONObject.java:198)
at org.json.JSONObject.<init>(JSONObject.java:325)
at metar.principale.main(principale.java:13)
Can someone help me please I am unable to find where is the problem, thank you.