J
J
Julia Vorobieva2017-04-02 19:23:42
Java
Julia Vorobieva, 2017-04-02 19:23:42

Problems reading JSON file. How to get rid of "Lexical Error: Unmatched Input."?

Good morning everyone :) Please help me to deal with the error, I broke my whole head. There is a JSON file with the following content (There are only 30 objects in the array, I won't cram everything here).

{
   «FileName»:«student»,
   «Students»: [
   {
       «ID»: «1»,
       «Fio»: «Акулеев Кирилл Андреевич»,
       «Group»: «16-IVT-2»,
       «Num»: 10
   },
   {
       «ID»: 2,
       «Fio»: «Алексейчик Андрей Александрович»,
       «Group»: «16-IVT-2»,
      «Num»: 11
    } 
   ]
}

The second day I unsuccessfully try to read it using the functions of the json-simple library and re-read a bunch of sites on the subject. Right now my code looks like this and throws "java.lang.Error: Lexical Error: Unmatched Input."
public static void main(String[] args)  throws  FileNotFoundException,
            IOException, Exception {
        JSONParser parser = new JSONParser();
        Object Students = parser.parse(new FileReader("/Users/yuliavorobjeva/Desktop/Students.JSON"));
        JSONObject jsonStudents = (JSONObject) Students;
        String FileName = (String) jsonStudents.get("FileName");
        System.out.printf("%s", FileName);
        JSONArray people = (JSONArray)jsonStudents.get("Students");
        for(Object o: people){
            JSONObject person= (JSONObject)o;
            int Id = (int)person.get("ID");
            String name = (String) person.get("Fio");
            String  group = (String) person.get("Group");
            int num = (int) person.get("Num");
        }


    }

As I understand it, I first read the string "FileName", and then I try to read the array. I don't see the error point blank: s. Please help me figure out what exactly I'm doing wrong and how to fix it. Thanks in advance:)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pushkarev, 2017-04-02
@Yulets

The quotes must be " , not ""

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question