Reading first json with this name TestNameUS.json from the amazon S3Client directory and getting the sql from it and then hitting the db using the sql and matching the result with other Amazon S3 output directory containing the TestNameUS.csv with the same name as the name of the first json. My code is below. It gives me the sql.How to read the directory dynamically with the name
public class ReadJsonFile {
public static void main(String[] args) {
// TODO Auto-generated method stub
JSONParser jsonParser = new JSONParser();
try {
Object obj = jsonParser.parse(new FileReader("./TestNameUS.json"));
// A JSON object. Key value pairs are unordered. JSONObject supports java.util.Map interface.
JSONObject jsonObject = (JSONObject) obj;
JSONArray query = (JSONArray) jsonObject.get("query");
String query1=null;
for(Object str : query) {
query1=(String)str;
}
System.out.println(query1);
System.out.println(query1.replaceAll("^\\('|\\'\\)$", ""));
} catch (Exception e) {
e.printStackTrace();
}
}
}