Package bgu.bio.io.file.json

Examples of bgu.bio.io.file.json.JSONArray


  }

  public static FixedStepRangesTable BuildFromJSON(JSONObject json) {
    FixedStepRangesTable table = null;
    try {
      JSONArray a = json.getJSONArray("rangetable");
      int len = a.length();
      table = new FixedStepRangesTable(json.getDouble("first"),
          json.getDouble("last"), json.getDouble("step"));
      for (int i = 0; i < len; i++) {
        JSONArray b = a.getJSONArray(i);
        Range r = table.getRange(b.getDouble(0));
        r.setTuplePassed(b.getInt(1));
        r.setTupleFailed(b.getInt(2));
      }
    } catch (JSONException e) {
      e.printStackTrace();
    }
    return table;
View Full Code Here


  }

  public JSONObject toJSON() throws JSONException {
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("nodes", this.getNodeNum());
    JSONArray array = new JSONArray();
    for (int i = 0; i < nodeNum; i++) {
      JSONArray inner = new JSONArray();
      TIntArrayList adj = adjLists.get(i);
      for (int d = 0; d < adj.size(); d++) {
        if (adj.get(d) > i) {
          inner.put(adj.get(d));
        }
      }
      array.put(inner);
    }
    jsonObject.put("edges", array);
View Full Code Here

      throws JSONException {
    FlexibleUndirectedGraph graph = new FlexibleUndirectedGraph();
    for (int i = 0; i < json.getInt("nodes"); i++) {
      graph.addNode();
    }
    JSONArray edges = json.getJSONArray("edges");
    for (int i = 0; i < graph.getNodeNum(); i++) {
      JSONArray current = edges.getJSONArray(i);
      for (int x = 0; x < current.length(); x++) {
        graph.addEdge(i, current.getInt(x));
      }
    }
    return graph;
  }
View Full Code Here

TOP

Related Classes of bgu.bio.io.file.json.JSONArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.