I have a json file, for example:
{
  "A":"-0.4",
  "B":"-0.2",
  "C":"-0.2",
  "D":"X",
  "E":"0.2",
  "F":"0.2",
  "J":"0.3"
}
I want return each element of a list json when I call it via my function. I did a function to do this:
public JSONObject my_function() {
JSONParser parser = new JSONParser();
    List<JSONObject> records = new ArrayList<JSONObject>();
    try (FileReader reader = new FileReader("File.json")) {
        //Read JSON file
        Object obj = parser.parse(reader);
        JSONObject docs = (JSONObject) obj;
        LOGGER.info("read elements" + docs); // it display all a list of a json file like this: {"A":"-0.4","B":"-0.2","C":"-0.2","D":"X","E":"0.2","F":"0.2","J":"0.3"}
        for (int i = 0; i < docs.size(); i++) {
            records.add((JSONObject) docs.get(i));
            System.out.println((records)); // it return null 
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (ParseException e) {
        e.printStackTrace();
    }
    LOGGER.info("The first element of a list is:" +records.get(0)); // return null
    return records.get(0);
How can I change my function to return the value of each element in a json file. For example, when I call my_function:
my_function.get("A") should display -0.4
Thank you
 
     
    