JSONObject objtwo = featuresObj.getJSONObject(sw.getDpid());
JSONArray jsontwo = objtwo.getJSONArray("ports");
for(int i = 0; i < json.length(); i++)
{
obj = (JSONObject)json.get(i);
Port port = new Port(String.valueOf(obj.getInt("portNumber")));
port.setReceivePackets(FormatLong.formatPackets(obj.getLong("receivePackets"), false, false));
port.setTransmitPackets(FormatLong.formatPackets(obj.getLong("transmitPackets"), false, false));
port.setReceiveBytes(FormatLong.formatBytes(obj.getLong("receiveBytes"), true, false));
port.setTransmitBytes(FormatLong.formatBytes(obj.getLong("transmitBytes"), true, false));
port.setReceiveDropped(String.valueOf(obj.getLong("receiveDropped")));
port.setTransmitDropped(String.valueOf(obj.getLong("transmitDropped")));
port.setReceiveErrors(String.valueOf(obj.getLong("receiveErrors")));
port.setTransmitErrors(String.valueOf(obj.getLong("transmitErrors")));
port.setReceieveFrameErrors(String.valueOf(obj.getInt("receiveFrameErrors")));
port.setReceieveOverrunErrors(String.valueOf(obj.getInt("receiveOverrunErrors")));
port.setReceiveCRCErrors(String.valueOf(obj.getInt("receiveCRCErrors")));
port.setCollisions(String.valueOf(obj.getInt("collisions")));
if(!jsontwo.isNull(i))
{
obj = (JSONObject)jsontwo.get(i);
port.setAdvertisedFeatures(String.valueOf(obj.getInt("advertisedFeatures")));
port.setConfig(String.valueOf(obj.getInt("config")));
port.setCurrentFeatures(String.valueOf(obj.getInt("currentFeatures")));
port.setHardwareAddress(obj.getString("hardwareAddress"));
port.setName(obj.getString("name"));
port.setPeerFeatures(String.valueOf(obj.getInt("peerFeatures")));
port.setState(String.valueOf(obj.getInt("state")));
port.setSupportedFeatures(String.valueOf(obj.getInt("supportedFeatures")));
}
ports.add(port);
}
sw.setPorts(ports);