I am getting errors that the JSON objects and file reader objects cannot be found. However, I have imported the correct libraries and it still does not work. The code I have until now is as follows:
import org.json.*;
import java.sql.*;
import java.io.*;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Test {
private static HashSet<String> seenAttributes = new HashSet<>();
public static void parseBusinessData() {
FileReader fileReader = null;
BufferedReader bufferedReader = null;
String filePath = "C:/Users/jay/documents/c_______/yelp_business.json";
try {
fReader = new FileReader(filePath);
bufferedReader = new BufferedReader(fileReader);
String line;
bufferedReader.readLine();
int index = 0;
while ((line = bufferedReader.readLine()) != null) {
JSONObject obj = new JSONObject(line);
/*
CREATE TABLE Business_Attributes (
Business_Id char(22) NOT NULL,
Attribute_Id number(5) NOT NULL,
CREATE TABLE Attributes (
Attribute_Id number(5) NOT NULL,
Attribute_Name varchar2(50) NOT NULL,
*/
JSONArray attributeArray = obj.getJSONArray("attributes");
for(int i = 0; i < attributeArray.length; i++){
String attribute = attributeArray.getString(i);
System.out.println("Attribute = " + attribute);
if(!seenAttributes.contains(attribute)){
seenAttributes.add(attribute);
}
}
}
} catch (FileNotFoundException ex) {
Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
bufferedReader.close();
fReader.close();
} catch (IOException ex) {
Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
public static void main(String[] args){
parseBusinessData();
}
}
And I get the following errors:
Test.java:23: error: cannot find symbol
fReader = new FileReader(filePath);
^
symbol: variable fReader
location: class Test
Test.java:29: error: cannot find symbol
JSONObject obj = new JSONObject(line);
^
symbol: class JSONObject
location: class Test
Test.java:29: error: cannot find symbol
JSONObject obj = new JSONObject(line);
^
symbol: class JSONObject
location: class Test
Test.java:41: error: cannot find symbol
JSONArray attributeArray = obj.getJSONArray("attributes");
^
symbol: class JSONArray
location: class Test
Test.java:58: error: cannot find symbol
fReader.close();
^
symbol: variable fReader
location: class Test
5 errors
It would be great if you could help me resolve these errors! I've spent a lot of time on this and don't seem to know what's the issue here. From what I've read online, I need to download some jar files but I'm not sure which ones.