app/src/main/java/com/example/android/quakereport/QueryUtils.java
private static ArrayList<EarthquakeData> extractEarthquakes(String JSON_RESPONSE) {

        // Create an empty ArrayList that we can start adding earthquakes to
        ArrayList<EarthquakeData> earthquakes = new ArrayList<>();

        // Try to parse the SAMPLE_JSON_RESPONSE. If there's a problem with the way the JSON
        // is formatted, a JSONException exception object will be thrown.
        // Catch the exception so the app doesn't crash, and print the error message to the logs.


        try {

            // TODO: Parse the response given by the SAMPLE_JSON_RESPONSE string and
            // build up a list of Earthquake objects with the corresponding data.
            JSONObject jsonobject=new JSONObject(JSON_RESPONSE);
            JSONArray FeatureArray=jsonobject.optJSONArray("features");
            for (int i=0;i<FeatureArray.length();i++){
                JSONObject jsonFeatureObject = FeatureArray.getJSONObject(i);
                JSONObject propertiesObject = jsonFeatureObject.getJSONObject("properties");
                double Magnitude=propertiesObject.optDouble("mag");
                String Place=propertiesObject.optString("place");
                long time=propertiesObject.optLong("time");
                String URLsite=propertiesObject.optString("url");
                EarthquakeData ob=new EarthquakeData(Magnitude,Place,time,URLsite);
                earthquakes.add(ob);
            }

        } catch (JSONException e) {
            // If an error is thrown when executing any of the above statements in the "try" block,
            // catch the exception here, so the app doesn't crash. Print a log message
            // with the message from the exception.
            Log.e("QueryUtils", "Problem parsing the earthquake JSON results", e);
        }

        // Return the list of earthquakes
        return earthquakes;
    }
/**
     * Return a list of {@link EarthquakeData} objects that has been built up from
     * parsing a JSON response.
     */
Return a list of  EarthquakeData objects that has been built up from
parsing a JSON response.
Return a list of EarthquakeData objects that has been built up from parsing a JSON response .
private static ArrayList<EarthquakeData> extractEarthquakes(String JSON_RESPONSE) {
        ArrayList<EarthquakeData> earthquakes = new ArrayList<>();
        try {
            JSONObject jsonobject=new JSONObject(JSON_RESPONSE);
            JSONArray FeatureArray=jsonobject.optJSONArray("features");
            for (int i=0;i<FeatureArray.length();i++){
                JSONObject jsonFeatureObject = FeatureArray.getJSONObject(i);
                JSONObject propertiesObject = jsonFeatureObject.getJSONObject("properties");
                double Magnitude=propertiesObject.optDouble("mag");
                String Place=propertiesObject.optString("place");
                long time=propertiesObject.optLong("time");
                String URLsite=propertiesObject.optString("url");
                EarthquakeData ob=new EarthquakeData(Magnitude,Place,time,URLsite);
                earthquakes.add(ob);
            }
        } catch (JSONException e) {
            Log.e("QueryUtils", "Problem parsing the earthquake JSON results", e);
        }
        return earthquakes;
    }
private static ArrayList < EarthquakeData > extractEarthquakes ( String JSON_RESPONSE ) { ArrayList < EarthquakeData > earthquakes = new ArrayList < > ( ) ; try { JSONObject jsonobject = new JSONObject ( JSON_RESPONSE ) ; JSONArray FeatureArray = jsonobject . optJSONArray ( "features" ) ; for ( int i = 0 ; i < FeatureArray . length ( ) ; i ++ ) { JSONObject jsonFeatureObject = FeatureArray . getJSONObject ( i ) ; JSONObject propertiesObject = jsonFeatureObject . getJSONObject ( "properties" ) ; double Magnitude = propertiesObject . optDouble ( "mag" ) ; String Place = propertiesObject . optString ( "place" ) ; long time = propertiesObject . optLong ( "time" ) ; String URLsite = propertiesObject . optString ( "url" ) ; EarthquakeData ob = new EarthquakeData ( Magnitude , Place , time , URLsite ) ; earthquakes . add ( ob ) ; } } catch ( JSONException e ) { Log . e ( "QueryUtils" , "Problem parsing the earthquake JSON results" , e ) ; } return earthquakes ; }
Return a list of {@link EarthquakeData} objects that has been built up from
 parsing a JSON response.
Return a list of { @link EarthquakeData } objects that has been built up from parsing a JSON response .
// Create an empty ArrayList that we can start adding earthquakes to // Try to parse the SAMPLE_JSON_RESPONSE. If there's a problem with the way the JSON // is formatted, a JSONException exception object will be thrown. // Catch the exception so the app doesn't crash, and print the error message to the logs. // TODO: Parse the response given by the SAMPLE_JSON_RESPONSE string and // build up a list of Earthquake objects with the corresponding data. // If an error is thrown when executing any of the above statements in the "try" block, // catch the exception here, so the app doesn't crash. Print a log message // with the message from the exception. // Return the list of earthquakes