我尝试按照示例中的说明做同样的事情,但使用 JSON 而不是 XML
当我使用 XML 执行此操作时,它工作得很好,但是当我使用 JSON 时它只加载第一个孩子。
这是 XML:
<response>
<errors />
<data>
<project>
<id>3</id>
<name>Checho Project</name>
<sprints>
<project>
<id>4</id>
<name>Backlog</name>
</project>
</sprints>
</project>
</data>
</response>
这是 JSON:
{"response":
{"errors":"","data":
{"project":[{"id":1,"name":"Bee Project","sprints":
{"project":[{"id":3,"name":"sprint3"},{"id":4,"name":"sprint2"},{"id":2,"name":"sprint1"}]}},
{"id":5,"name":"Checho Project","sprints":
{"project":{"id":6,"name":"Backlog"}}}]
}
}
}
private ProjectDS(String id) {
setID(id);
setRecordXPath("/response/data/*");
// setRecordXPath("/Employees/*");
// DataSourceTextField nameField = new DataSourceTextField("Name", "Name", 128);
//
// DataSourceIntegerField employeeIdField = new DataSourceIntegerField("EmployeeId", "Employee ID");
// employeeIdField.setPrimaryKey(true);
// employeeIdField.setRequired(true);
DataSourceTextField idField = new DataSourceTextField("id", "Id", 128, true);
idField.setHidden(true);
idField.setPrimaryKey(true);
DataSourceTextField itemNameField = new DataSourceTextField("name", "Item", 128, true);
DataSourceField reportsToField = new DataSourceField();
reportsToField.setName("sprints");
reportsToField.setChildrenProperty(true);
setFields(idField, itemNameField, reportsToField);
setDataFormat(DSDataFormat.JSON);
setDataURL("bee_gui/sc/ds.xml");
setClientOnly(true);
}
有人处理过这个吗?
谢谢!