转json存储后,不能直接展示字符串,所以需要将字符串 再转成对象提取一下,上代码。
Object addrPhone = map.get("addrPhone");
//得到字符串
String stringAddrPhone = map.get("addrPhone").toString();
//转json对象存储
JSONObject jsonObject = JSONObject.parseObject(stringAddrPhone);
if (jsonObject != null){
//得到这个对象的值
String companyAddress = jsonObject.getString("companyAddress");
String companyPhone = jsonObject.getString("companyPhone");
//放到string 数组里
String[] strings = {companyAddress,companyPhone};
if (addrPhone != null){
//转换一下
map.put("addrPhoneStr",strings);
}
}
ok 可能我描述的也不对吧, 因为我现在也不太懂,写着写着应该就懂了。