if (javaObject instanceof Map) {
Map<Object, Object> map = (Map<Object, Object>) javaObject;

JSONObject json = new JSONObject(map.size());

for (Map.Entry<Object, Object> entry : map.entrySet()) {
Object key = entry.getKey();
String jsonKey = TypeUtils.castToString(key);
Object jsonValue = toJSON(entry.getValue());
json.put(jsonKey, jsonValue);
}

return json;
}

相关文章:

  • 2021-08-06
  • 2022-02-14
  • 2022-02-16
  • 2021-09-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
猜你喜欢
  • 2022-12-23
  • 2022-01-09
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
相关资源
相似解决方案