package conf.reader;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.internal.LinkedTreeMap;
import com.google.gson.reflect.TypeToken;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.*;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;


public class getJsonValues {

    public static void main(String[] args) throws IOException, ParseException {

        Gson gson = new Gson();
        JsonElement json = gson.fromJson(new FileReader("src/main/resources/tests.json"), JsonElement.class);
        String result = gson.toJson(json);

//        Map map = gson.fromJson(result, Map.class);
//        System.out.println(map.get("getAttachmentRest"));

        LinkedTreeMap testNames = gson.fromJson(result , LinkedTreeMap.class);

        for (Object i : testNames.keySet()) {
            LinkedTreeMap tests = gson.fromJson(testNames.get(i.toString()).toString(), LinkedTreeMap.class);

            for (Object o : tests.keySet()) {
                LinkedTreeMap testDetails = gson.fromJson(tests.get(o.toString()).toString(), LinkedTreeMap.class);
                Integer threads = (int) Double.parseDouble(testDetails.get("threads").toString());
                Integer duration = (int) Double.parseDouble(testDetails.get("duration").toString());
                Integer size = (int) Double.parseDouble(testDetails.get("size").toString());

                System.out.println(i.toString());
                System.out.println(threads);
                System.out.println(duration);
                System.out.println(size);
            }


        }

    }

}
