Example usage for com.google.gson JsonElement getAsJsonObject

List of usage examples for com.google.gson JsonElement getAsJsonObject

Introduction

In this page you can find the example usage for com.google.gson JsonElement getAsJsonObject.

Prototype

public JsonObject getAsJsonObject() 

Source Link

Document

convenience method to get this element as a JsonObject .

Usage

From source file:serverSocket.java

License:Apache License

public JsonObject sortJson(JsonArray arr) {

    List<JsonObject> tmp = new ArrayList<JsonObject>();
    for (JsonElement obj : arr) {
        tmp.add(obj.getAsJsonObject());
    }/*from   w  ww .  j a v a2  s  .  c  om*/
    Collections.sort(tmp, new Comparator<JsonObject>() {
        @Override
        public int compare(JsonObject a, JsonObject b) {
            return (int) (a.get("epoch").getAsLong() - b.get("epoch").getAsLong());
        }
    });

    //classify by time slots
    long start = tmp.get(0).get("epoch").getAsLong();
    //15 mins
    long slot = 15L * 60L;

    start += slot;
    JsonArray collection = new JsonArray();
    JsonObject done = new JsonObject();
    for (JsonObject obj : tmp) {
        if (obj.get("epoch").getAsLong() > start) {
            done.add(String.valueOf(start), collection);
            start = obj.get("epoch").getAsLong();
            start += slot;
            collection = new JsonArray();
            collection.add(obj);
        } else {
            collection.add(obj);

        }

    }

    return done;
}

From source file:serverSocket.java

License:Apache License

public String queryKeyHistroy(String keyw) {

    JsonObject query1 = new JsonObject();

    JsonObject query0 = new JsonObject();
    query0.addProperty("key", keyw);
    //query0.addProperty("sentiment", 5);

    JsonObject query4 = new JsonObject();
    query4.add("term", query0);
    query1.add("query", query4);
    query1.addProperty("from", 0);
    query1.addProperty("size", 10000);

    String response1 = HttpRequest.post(esURL1).send(query1.toString()).body();
    JsonObject sr1 = jsonParser.parse(response1).getAsJsonObject();
    JsonArray asr1 = sr1.get("hits").getAsJsonObject().get("hits").getAsJsonArray();

    JsonObject line = new JsonObject();
    for (JsonElement x : asr1) {
        line.add(x.getAsJsonObject().get("_source").getAsJsonObject().get("tid").toString(),
                x.getAsJsonObject().get("_source"));
    }//from   w  w w. j ava2s .  c  o m

    JsonObject res = new JsonObject();
    res.add("update", line);

    return res.toString();

}

From source file:PanicDetect.java

License:Apache License

private void listRegex() {
    try {//  www  . j av a  2s  . c o  m
        String result = RunnerRepository.getRPCClient()
                .execute("panicDetectConfig", new Object[] { RunnerRepository.getUser(), "list" }).toString();
        JsonElement jelement = new JsonParser().parse(result);
        JsonObject main = jelement.getAsJsonObject();
        JsonObject regex = main.getAsJsonObject(RunnerRepository.getUser());
        Iterator<Map.Entry<String, JsonElement>> iter = regex.entrySet().iterator();
        while (iter.hasNext()) {
            Map.Entry<String, JsonElement> n = iter.next();
            String id = n.getKey();
            JsonElement content = n.getValue();
            JsonObject ob = content.getAsJsonObject();
            String exp = ob.get("expression").getAsString();
            String en = ob.get("enabled").getAsString();
            MyPanel panel = new MyPanel(exp, Boolean.parseBoolean(en), id);
            addPanel(panel);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:galaxy_server.java

@Override
public boolean sendFile(String filePath) throws Exception {
    String url = this.getHost() + "/api/histories/most_recently_used";

    HashMap<String, String> params = new HashMap<>();
    params.put("key", this.getApiKey());

    String response = this.sendGet(url, params);
    JsonElement jelement = new JsonParser().parse(response);
    String historyID = jelement.getAsJsonObject().get("id").getAsString();

    String charset = "UTF-8";
    url = this.getHost() + "/api/tools/";

    MultipartUtility multipart = new MultipartUtility(url, charset);
    multipart.addFormField("key", this.getApiKey());
    multipart.addFormField("inputs",
            "{\"dbkey\":\"?\",\"file_type\":\"txt\",\"files_0|type\":\"upload_dataset\",\"files_0|space_to_tab\":null,\"files_0|to_posix_lines\":\"Yes\"}");
    multipart.addFormField("tool_id", "upload1");
    multipart.addFormField("history_id", historyID);
    multipart.addFilePart("files_0|file_data", new File(filePath));
    multipart.finish();//from  w w  w  .j a  va  2 s .  c  om
    return true;
}

From source file:GeoLocation.java

public static void main(String args[]) {
    try {//from   ww  w.j a  v a2 s  .com

        URL myURL = new URL(
                "https://maps.googleapis.com/maps/api/geocode/json?latlng=17.451425,%2078.380957&key=AIzaSyDe_RBKl4DBGy6YCWRPXi9eQzYACt05Tr8");
        URLConnection myURLConnection = myURL.openConnection();
        myURLConnection.connect();
        BufferedReader in = new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()));

        StringBuilder sb = new StringBuilder();

        String line = null;

        while ((line = in.readLine()) != null) {
            sb.append(line + "\n");
        }

        JsonElement json = new JsonParser().parse(sb.toString());
        JsonObject j = json.getAsJsonObject();
        JsonElement je = j.get("results");
        JsonArray ja = je.getAsJsonArray();
        JsonElement je1 = ja.get(1);
        JsonObject j1 = je1.getAsJsonObject();
        JsonElement je2 = j1.get("formatted_address");
        System.out.println(je2.getAsString());
    } catch (MalformedURLException e) {
        // new URL() failed
        // ...
    } catch (IOException e) {
        // openConnection() failed
        // ...
    }

}

From source file:RunnerRepository.java

License:Apache License

public static void parseIni(File ini) {
    try {/*from  w ww .  j av a 2s  .  c om*/
        FileInputStream in = new FileInputStream(ini);
        InputStreamReader inputStreamReader = new InputStreamReader(in);
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
        StringBuffer b = new StringBuffer("");
        String line;
        try {
            while ((line = bufferedReader.readLine()) != null) {
                b.append(line);
            }
            bufferedReader.close();
            inputStreamReader.close();
            in.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        JsonElement jelement = new JsonParser().parse(b.toString());
        inifile = jelement.getAsJsonObject();
        editors = inifile.getAsJsonObject("editors");
        looks = inifile.getAsJsonObject("looks");
        layout = inifile.getAsJsonObject("layout");
        plugins = inifile.getAsJsonArray("plugins");
        if (layout == null) {
            inifile.add("layout", new JsonObject());
            writeJSon();
            layout = inifile.getAsJsonObject("layout");
        }
        if (plugins == null) {
            inifile.add("plugins", new JsonArray());
            writeJSon();
            plugins = inifile.getAsJsonArray("plugins");
        }
    } catch (Exception e) {
        System.out.print("Could not parse ini file: ");
        try {
            System.out.println(ini.getCanonicalPath());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        e.printStackTrace();
    }
}

From source file:JavaTestRunner.java

License:Apache License

public static Object runQuery(JavaQuery query, String combinedInput) {
    JsonElement jelement = new JsonParser().parse(combinedInput);
    JsonObject jobject = jelement.getAsJsonObject();
    return runQuery(query, jobject);
}

From source file:EAIJSONConverter.java

License:Open Source License

public static SiebelPropertySet JsonObjectToPropertySet(JsonObject obj, SiebelPropertySet ps) {
    Iterator<Entry<String, JsonElement>> iterator = obj.entrySet().iterator();
    SiebelPropertySet child;/*from  w ww .  j  a v a 2 s .  c  o m*/
    while (iterator.hasNext()) {
        JsonArray jsonArray = new JsonArray();
        JsonObject jsonObject = new JsonObject();
        Map.Entry mapEntry = (Map.Entry) iterator.next();
        if (mapEntry != null) {
            JsonElement jsonelement = (JsonElement) mapEntry.getValue();
            if (jsonelement.isJsonArray()) {
                jsonArray = jsonelement.getAsJsonArray();
                child = new SiebelPropertySet();
                child.setType("ListOf-" + mapEntry.getKey().toString());
                for (int i = 0; i < jsonArray.size(); i++) {
                    if (jsonArray.get(i).isJsonObject() || jsonArray.get(i).isJsonArray()) {
                        SiebelPropertySet temp = new SiebelPropertySet();
                        temp.setType("" + i);
                        if (jsonArray.get(i).isJsonObject())
                            child.addChild(JsonObjectToPropertySet(jsonArray.get(i).getAsJsonObject(), temp));
                        else {
                            JsonObject aux = new JsonObject();
                            aux.add("" + i, jsonArray.get(i));
                            child.addChild(JsonObjectToPropertySet(aux, temp));

                        }
                    } else
                        child.setProperty("" + i, jsonArray.get(i).getAsString());
                }
                ps.addChild(child);
            } else if (jsonelement.isJsonObject()) {
                jsonObject = jsonelement.getAsJsonObject();
                child = new SiebelPropertySet();
                child.setType(mapEntry.getKey().toString());
                ps.addChild(JsonObjectToPropertySet(jsonObject, child));
            } else {
                ps.setProperty(mapEntry.getKey().toString(), mapEntry.getValue().toString());
            }
        }
    }

    return ps;
}

From source file:PacketSnifferPlugin.java

License:Apache License

public void initializeMainPanel() {
    try {//from   ww w  .  j av  a 2  s  .c om

        bstart = new JButton("Start");
        breset = new JButton("Reset");

        JPanel panel1 = new JPanel();
        panel1.setLayout(null);

        panel1.setMaximumSize(new Dimension(1150, 700));
        panel1.setMinimumSize(new Dimension(1150, 700));
        panel1.setPreferredSize(new Dimension(1150, 700));

        InputStream in = getClass().getResourceAsStream("Sniff0.png");
        Image im = ImageIO.read(in);
        button0 = new ImageIcon(im);
        in = getClass().getResourceAsStream("Sniff1.png");
        im = ImageIO.read(in);
        final ImageIcon button1 = new ImageIcon(im);
        in = getClass().getResourceAsStream("Stop1.png");
        im = ImageIO.read(in);
        final ImageIcon button2 = new ImageIcon(im);
        in = getClass().getResourceAsStream("Stop0.png");
        im = ImageIO.read(in);
        button3 = new ImageIcon(im);
        in = getClass().getResourceAsStream("Reset1.png");
        im = ImageIO.read(in);
        final ImageIcon button5 = new ImageIcon(im);
        in = getClass().getResourceAsStream("Save.png");
        im = ImageIO.read(in);
        ImageIcon save = new ImageIcon(im);

        breset.setBounds(515, 635, 120, 30);
        panel1.add(breset);
        breset.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                try {
                    String resp = client
                            .execute("runPlugin",
                                    new Object[] { variables.get("user"), getName(), "command=reset" })
                            .toString();
                    ((DefaultTableModel) jTable1.getModel()).setNumRows(0);
                    index = "0";
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        bstart = new JButton("Start");
        bstart.setBounds(385, 635, 120, 30);
        panel1.add(bstart);
        bstart.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (start == 1) {
                    bstart.setText("Start");
                    start = 0;
                    try {
                        String resp = client
                                .execute("runPlugin",
                                        new Object[] { variables.get("user"), getName(), "command=pause" })
                                .toString();
                        System.out.println("resp: " + resp);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                } else {
                    bstart.setText("Stop");
                    start = 1;
                    try {
                        String resp = client
                                .execute("runPlugin",
                                        new Object[] { variables.get("user"), getName(), "command=resume" })
                                .toString();
                        System.out.println("resp: " + resp);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            }
        });

        jTable1 = new JTable();
        jTable1.getTableHeader().setReorderingAllowed(false);
        jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        jTable1.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent arg0) {
                if (!arg0.getValueIsAdjusting()) {
                    if (jTable1.getSelectedRow() == -1) {
                        content.setText("");
                        return;
                    }
                    String pac = null;
                    try {
                        String id = jTable1.getValueAt(jTable1.getSelectedRow(), 7).toString();
                        System.out.println("requested id: " + id);
                        pac = client.execute("runPlugin", new Object[] { variables.get("user"), getName(),
                                "command=querypkt&data=" + id }).toString();
                        JsonElement el = new JsonParser().parse(pac);
                        JsonObject jobject = el.getAsJsonObject();
                        Gson gson = new GsonBuilder().setPrettyPrinting().create();
                        String json = gson.toJson(jobject);
                        json = json.replaceAll("\"", "");
                        json = json.replaceAll("\\\\n", "\n");
                        content.setText(json);
                    } catch (Exception e) {
                        System.out.println("Server response: " + pac.toString());
                        e.printStackTrace();

                    }
                }
            }
        });

        JScrollPane pane = new JScrollPane(jTable1);
        pane.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
        pane.setBounds(25, 70, 1100, 300);

        jTable1.setModel(new DefaultTableModel(new Object[][] {}, new String[] { "Protocol", "SRC IP",
                "SRC Mac", "SRC Port", "DST IP", "DST Mac", "DST Port", "" }) {
            private static final long serialVersionUID = 1L;

            public boolean isCellEditable(int row, int col) {
                return false;
            }
        });
        TableRowSorter sorter = new TableRowSorter(jTable1.getModel());
        jTable1.setRowSorter(sorter);
        TableColumn c = jTable1.getColumnModel().getColumn(7);
        c.setMinWidth(0);
        c.setMaxWidth(0);
        c.setWidth(0);
        c.setPreferredWidth(0);
        panel1.add(pane);

        content = new JTextArea();
        content.setEditable(false);
        JScrollPane sc = new JScrollPane(content);
        sc.setBounds(25, 380, 1100, 250);
        panel1.add(sc);

        JPanel top = new JPanel();
        top.setBounds(25, 0, 1100, 35);
        panel1.add(top);

        JPanel top2 = new JPanel();
        top2.setBounds(25, 35, 1100, 30);
        panel1.add(top2);

        JLabel filter = new JLabel("View Filter:");
        panel1.add(top);
        top.add(filter);
        final JTextField search = new JTextField();
        search.setMinimumSize(new Dimension(130, 20));
        search.setPreferredSize(new Dimension(130, 20));
        search.addKeyListener(new KeyAdapter() {
            public void keyReleased(KeyEvent ev) {
                if (ev.getKeyCode() == KeyEvent.VK_ENTER) {
                    filter(search.getText());
                }
            }
        });
        top.add(search);
        JButton apply = new JButton("Apply");
        apply.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                filter(search.getText());
            }
        });
        top.add(apply);
        JButton clear = new JButton("Clear");
        clear.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                search.setText("");
                filter("");
            }
        });
        top.add(clear);

        filter = new JLabel("Start Options:");
        top.add(filter);
        final JTextField search2 = new JTextField();
        search2.setMinimumSize(new Dimension(130, 20));
        search2.setPreferredSize(new Dimension(130, 20));
        search2.addKeyListener(new KeyAdapter() {
            public void keyReleased(KeyEvent ev) {
                if (ev.getKeyCode() == KeyEvent.VK_ENTER) {
                    setRemoteFilter(search2.getText());
                }
            }
        });
        try {
            HashMap<String, String> filters = (HashMap<String, String>) client.execute("runPlugin",
                    new Object[] { variables.get("user"), getName(), "command=getfilters" });
            Iterator<Entry<String, String>> iter = filters.entrySet().iterator();
            StringBuilder sb = new StringBuilder();
            Entry<String, String> en;
            while (iter.hasNext()) {
                en = iter.next();
                sb.append(en.getKey());
                sb.append(" ");
                sb.append(en.getValue());
                sb.append(" ");
            }
            System.out.println("Filter:" + sb.toString());
            search2.setText(sb.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        top.add(search2);
        JButton apply2 = new JButton("Apply");
        apply2.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                setRemoteFilter(search2.getText());
            }
        });
        top.add(apply2);
        JButton clear2 = new JButton("Clear");
        clear2.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                search2.setText("");
                setRemoteFilter("");

            }
        });
        top.add(clear2);

        pro = new JCheckBox("Protocol");
        pro.setSelected(true);
        pro.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                if (pro.isSelected()) {
                    jTable1.addColumn(columns[0]);
                    jTable1.moveColumn(jTable1.getColumnCount() - 1, 0);
                } else {
                    int index = findColumn("Protocol");
                    columns[0] = jTable1.getColumnModel().getColumn(index);
                    jTable1.removeColumn(columns[0]);
                }
            }
        });
        top2.add(pro);
        srcip = new JCheckBox("SRC IP");
        srcip.setSelected(true);
        srcip.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                if (srcip.isSelected()) {
                    int index = findColumn("Protocol");
                    if (index == -1) {
                        jTable1.addColumn(columns[1]);
                        jTable1.moveColumn(jTable1.getColumnCount() - 1, 0);
                    } else {
                        jTable1.addColumn(columns[1]);
                        jTable1.moveColumn(jTable1.getColumnCount() - 1, 1);
                    }
                } else {
                    int index = findColumn("SRC IP");
                    columns[1] = jTable1.getColumnModel().getColumn(index);
                    jTable1.removeColumn(columns[1]);
                }
            }
        });
        top2.add(srcip);
        srcmac = new JCheckBox("SRC Mac");
        srcmac.setSelected(true);
        srcmac.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                if (srcmac.isSelected()) {
                    jTable1.addColumn(columns[2]);
                    int index = findColumn("SRC IP");
                    if (index != -1) {
                        jTable1.moveColumn(jTable1.getColumnCount() - 1, index + 1);
                    } else if (findColumn("Protocol") != -1) {
                        jTable1.moveColumn(jTable1.getColumnCount() - 1, 1);
                    } else {
                        jTable1.moveColumn(jTable1.getColumnCount() - 1, 0);
                    }
                } else {
                    int index = findColumn("SRC Mac");
                    columns[2] = jTable1.getColumnModel().getColumn(index);
                    jTable1.removeColumn(columns[2]);
                }
            }
        });
        top2.add(srcmac);
        srcport = new JCheckBox("SRC Port");
        srcport.setSelected(true);
        srcport.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                if (srcport.isSelected()) {
                    jTable1.addColumn(columns[3]);
                    int index = findColumn("SRC Mac");
                    if (index != -1) {
                        jTable1.moveColumn(jTable1.getColumnCount() - 1, index + 1);
                    } else {
                        index = findColumn("SRC IP");
                        if (index != -1) {
                            jTable1.moveColumn(jTable1.getColumnCount() - 1, index + 1);
                        } else if (findColumn("Protocol") != -1) {
                            jTable1.moveColumn(jTable1.getColumnCount() - 1, 1);
                        } else {
                            jTable1.moveColumn(jTable1.getColumnCount() - 1, 0);
                        }
                    }
                } else {
                    int index = findColumn("SRC Port");
                    columns[3] = jTable1.getColumnModel().getColumn(index);
                    jTable1.removeColumn(columns[3]);
                }
            }
        });
        top2.add(srcport);
        dstip = new JCheckBox("DST IP");
        dstip.setSelected(true);
        dstip.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                if (dstip.isSelected()) {
                    jTable1.addColumn(columns[4]);
                    int index = findColumn("DST Mac");
                    if (index != -1) {
                        jTable1.moveColumn(jTable1.getColumnCount() - 1, index);
                    } else {
                        index = findColumn("DST Port");
                        if (index != -1) {
                            jTable1.moveColumn(jTable1.getColumnCount() - 1, index);
                        }
                    }
                } else {
                    int index = findColumn("DST IP");
                    columns[4] = jTable1.getColumnModel().getColumn(index);
                    jTable1.removeColumn(columns[4]);
                }
            }
        });
        top2.add(dstip);
        dstmac = new JCheckBox("DST Mac");
        dstmac.setSelected(true);
        dstmac.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                if (dstmac.isSelected()) {
                    jTable1.addColumn(columns[5]);
                    int index = findColumn("DST Port");
                    if (index != -1) {
                        jTable1.moveColumn(jTable1.getColumnCount() - 1, index);
                    }
                } else {
                    int index = findColumn("DST Mac");
                    columns[5] = jTable1.getColumnModel().getColumn(index);
                    jTable1.removeColumn(columns[5]);
                }
            }
        });
        top2.add(dstmac);
        dstport = new JCheckBox("DST Port");
        dstport.setSelected(true);
        dstport.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                if (dstport.isSelected()) {
                    jTable1.addColumn(columns[6]);
                } else {
                    int index = findColumn("DST Port");
                    columns[6] = jTable1.getColumnModel().getColumn(index);
                    jTable1.removeColumn(columns[6]);
                }
            }
        });
        top2.add(dstport);
        JButton bsave = new JButton(save);
        bsave.setToolTipText("Save as libpcap");
        bsave.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                saveFile();
            }
        });
        bsave.setBounds(645, 635, 120, 30);
        panel1.add(bsave);
        p.add(new JScrollPane(panel1));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:PacketSnifferPlugin.java

License:Apache License

public void updateTable(String command) {
    HashMap<String, HashMap> hash = null;
    try {/*from w  w  w.  j ava2 s  .co  m*/
        DefaultTableModel model = ((DefaultTableModel) jTable1.getModel());
        Object obj = client.execute("runPlugin",
                new Object[] { variables.get("user"), getName(), "command=query&data=" + index });
        //System.out.println("Response: "+obj.toString());

        hash = (HashMap<String, HashMap>) obj;
        //hash = (HashMap<String, HashMap>) client.execute("runPlugin",
        //      new Object[] { variables.get("user"), getName(),
        //            "command=query&data=" + index });
        HashMap hash2 = hash.get("data");
        if (hash2.isEmpty()) {
            return;
        }
        index = hash2.get("id").toString();
        //System.out.println("index: "+index);
        Object[] hash3 = (Object[]) hash2.get("packets");
        //System.out.println("packets length: "+hash3.length);

        String protocol, sip, smac, sport, dip, dmac, dport, id = null;
        for (Object ob : hash3) {
            try {
                JsonElement el = new JsonParser().parse(ob.toString());
                JsonObject jobject = el.getAsJsonObject();

                el = jobject.get("packet_head");
                jobject = el.getAsJsonObject();

                JsonElement source = jobject.get("source");
                jobject = source.getAsJsonObject();
                source = jobject.get("ip");
                sip = source.toString();
                sip = sip.substring(1, sip.length() - 1);
                source = jobject.get("mac");
                smac = source.toString();
                smac = smac.substring(1, smac.length() - 1);
                source = jobject.get("port");
                sport = source.toString();
                jobject = el.getAsJsonObject();
                source = jobject.get("destination");
                jobject = source.getAsJsonObject();
                source = jobject.get("ip");
                dip = source.toString();
                dip = dip.substring(1, dip.length() - 1);
                source = jobject.get("mac");
                dmac = source.toString();
                dmac = dmac.substring(1, dmac.length() - 1);
                source = jobject.get("port");
                dport = source.toString();
                jobject = el.getAsJsonObject();
                source = jobject.get("protocol");
                protocol = source.toString();
                protocol = protocol.substring(1, protocol.length() - 1);
                source = jobject.get("id");
                id = source.toString();
                id = id.substring(1, id.length() - 1);
                model.addRow(new Object[] { protocol, sip, smac, sport, dip, dmac, dport, id });
            } catch (Exception e) {
                System.out.println("Server response: " + hash.toString());
                e.printStackTrace();
            }
        }
        if (model.getRowCount() > length) {
            int delete = model.getRowCount() - length;
            for (int i = 0; i < delete; i++) {
                //System.out.println("delete");
                model.removeRow(0);
            }
        }
    } catch (Exception e) {
        System.out.println("Server response: " + hash.toString());
        e.printStackTrace();
    }

}