Example usage for org.json.simple JSONArray toArray

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

Introduction

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

Prototype

public Object[] toArray() 

Source Link

Document

Returns an array containing all of the elements in this list in proper sequence (from first to last element).

Usage

From source file:vitro.vgw.wsiadapter.TCSWSIAdapter.java

public List<Node> getAvailableNodeList() throws WSIAdapterException {

    String raw_data = doHttpGet("http://[aaaa::212:7401:1:101]");

    if (!raw_data.equals("")) {
        Object raw_obj = null;//from   w  w  w .  j a  v  a2 s . co m

        try {

            raw_obj = parser.parse(raw_data);
        } catch (ParseException pe) {

            System.out.println("position: " + pe.getPosition());
            System.out.println(pe);

        }

        System.out.println(raw_obj);

        JSONObject obj2 = (JSONObject) raw_obj;
        JSONArray raw_arr = (JSONArray) obj2.get("route");

        System.out.println("Routes are: " + raw_arr);

        //

        assert obj2 != null;
        //   JSONArray raw_arr = (JSONArray) obj2.get("address");

        //   System.out.println("Nodes are: " + raw_arr);
        Object[] objs = raw_arr.toArray();
        for (Object o : objs) {
            JSONObject id = (JSONObject) o;
            String ipaddr = ((String) id.get("address")).split("/")[0];
            Node n = new NodeDescriptor();

            Node m = new Node();

            n.setId(ipaddr);
            if (nodeList == null) {
                System.err.println("m vale " + m);
                return null;
            }
            nodeList.add((NodeDescriptor) n);

            m.setId(ipaddr);
            listofnode.add(m);

        }
    }
    return listofnode;
}