有没有办法将不同的字符串集合合并到一个 JSON“字符串”中?我想要一个如下所示的 JSON 字符串:
{"vendor":[Sun, HP, IBM],"product":[bla, bla, bla],"availability":[high, mid, low],"capacity":[bla, bla, bla], ...}
这是我的 Java 代码的一部分:
Collection<String> vendor = bh.getAllVendors();
Collection<String> product = bh.getProductsForVendor(vendor);
Collection<String> availability = bh.getAllAvailabilities();
Collection<String> capacity = bh.getCapacityForVendor(vendor);
Collection<String> signaling = bh.getSignalingForVendor(vendor);
Collection<String> backup = bh.getBackupForVendor(vendor);
Gson gson = new Gson();
任何帮助,将不胜感激。