Get data from JSON String in Java

时间:2018-07-24 10:04:03

标签: json jtable

I am getting the result from server as:

{"Results": [["person1", 30], ["person2", 30]], "ts": 1532422578}

I want to get the values and populate it to jTable. With this code, I am getting the complete string as output instead of "0x240001", 30, "0x240003", 30. Why this?

             JSONObject jsonObj = new JSONObject();
             JSONParser parser = new JSONParser();
             String s = "{\"Results\": [[\"person1\", 30], [\"person2\", 30]], \"ts\": 1532422578}";
             jsonObj.put("Result from Server",s);

             JSONArray jsonArray = new JSONArray();
             jsonArray.add(jsonObj);
             System.out.println("Array size"+ jsonArray.size());
             for (int i = 0; i < jsonArray.size(); i++)  { 
                    String value = jsonArray.get(i).toString();
                    System.out.println("Result");
                    System.out.println(value);
                    table_searchResult.addRow(new Object[]{value});
             }

0 个答案:

没有答案