@Test public void testConvertWithBranchLengths() { String json="{\"tree\":{ \"root\":{\"id\":0,\"children\":[{\"styleId\":\"1\",\"id\":1,\"name\":\"a\",\"children\":[],\"branchLength\":1},{\"styleId\":\"0\",\"id\":2,\"name\":\"b\",\"children\":[],\"branchLength\":2}]}}}"; JSONObject object; try { object = new JSONObject(json); Tree tree = BuildTreeFromJSON.buildTree(object); INode root=tree.getRootNode(); assertEquals(null,root.getBranchLength()); INode a = root.getChild(0); assertEquals(1.0,a.getBranchLength()); INode b = root.getChild(1); assertEquals(2.0,b.getBranchLength()); } catch (JSONException e) { e.printStackTrace(); } }
public static Tree buildTree(JSONObject object) throws JSONException { Node root = buildNode(object.getJSONObject("tree").getJSONObject("root")); Tree tree = new Tree(); tree.setId(0); tree.setRootNode((INode)root); return tree; }
BuildTreeFromJSON { public static Tree buildTree(JSONObject object) throws JSONException { Node root = buildNode(object.getJSONObject("tree").getJSONObject("root")); Tree tree = new Tree(); tree.setId(0); tree.setRootNode((INode)root); return tree; } }
BuildTreeFromJSON { public static Tree buildTree(JSONObject object) throws JSONException { Node root = buildNode(object.getJSONObject("tree").getJSONObject("root")); Tree tree = new Tree(); tree.setId(0); tree.setRootNode((INode)root); return tree; }  }
BuildTreeFromJSON { public static Tree buildTree(JSONObject object) throws JSONException { Node root = buildNode(object.getJSONObject("tree").getJSONObject("root")); Tree tree = new Tree(); tree.setId(0); tree.setRootNode((INode)root); return tree; }  static Tree buildTree(JSONObject object); static Node buildNode(JSONObject object); }
BuildTreeFromJSON { public static Tree buildTree(JSONObject object) throws JSONException { Node root = buildNode(object.getJSONObject("tree").getJSONObject("root")); Tree tree = new Tree(); tree.setId(0); tree.setRootNode((INode)root); return tree; }  static Tree buildTree(JSONObject object); static Node buildNode(JSONObject object);  }