背景

改一个以前的项目,项目里只有这个包,虽然我想用gson或者fastjson,然而并不想引入新的jar。于是使用这个,特此记录,感觉贼不好用。

实现代码

entity.getData()的值:{aaa:bbb}

JSONObject jsonObject = JSONObject.fromObject(entity.getData());
Map<String, String> result = new HashMap<String, String>();
Iterator<String> iterator = jsonObject.keys();
String key = null;
String value = null;
while (iterator.hasNext()) {
    key = iterator.next();
    value = jsonObject.getString(key);
    result.put(key, value);
}

相关文章:

  • 2022-01-05
  • 2021-12-06
  • 2022-12-23
  • 2022-01-11
  • 2021-05-30
  • 2022-12-23
  • 2021-06-20
猜你喜欢
  • 2021-08-30
  • 2021-05-22
  • 2021-09-27
  • 2022-12-23
  • 2021-06-29
  • 2022-02-09
  • 2022-02-23
相关资源
相似解决方案