0

我有一个非类型化的实体集合,并希望使用 JSONSimple 转换为 JSON 字符串。

我尝试过使用 JSONObject,例如:

Collection entities; //supose its a non-typed Collection returned from service.
JSONObject colJSON = new JSONObject();
colJSON.put("entities",entities);
JSONValue.toJSONString(colJSON);

但是,它只返回 Collection toString() 方法而不是 Collection 的元素;

4

1 回答 1

0

尝试使用列表而不是集合。我在 J SONSimple 支持的类型列表中没有看到“集合” 。

于 2012-01-03T22:10:21.890 回答