Example usage for org.json.simple JSONArray getClass

List of usage examples for org.json.simple JSONArray getClass

Introduction

In this page you can find the example usage for org.json.simple JSONArray getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:eu.juniper.MonitoringLib.java

private ArrayList<String> parseJsonMetrics(ArrayList<String> metricsList, String json)
        throws FileNotFoundException, IOException, ParseException {
    JSONParser parser = new JSONParser();
    Object obj = parser.parse(json);
    JSONArray jsonArray = new JSONArray();
    String metric;/*from  w w w .  j  a  va  2s . c om*/

    if (obj.getClass() != jsonArray.getClass()) {
        System.out.println("Total number of metrics = 0");
        System.out.println("obj = " + obj.toString());
        return metricsList;
    }

    jsonArray = (JSONArray) obj;

    System.out.println("Total number of metrics = " + jsonArray.size());

    for (int i = 0; i < jsonArray.size(); i++) {
        metric = jsonArray.get(i).toString();
        metricsList.add(metric);
        System.out.println("metric # " + i + " = " + metric);

    }
    return metricsList;
}