标签:报错 nbsp div bsp 数组 sharp class 类型 object
1. JsonString转为Map
String jsoNStr = "{\n" + "\t\"TestArray\": [\"1\", \"2\", \"3\"]\n" + "}"; Map map = JSON.parseObject(jsoNStr,Map.class);
2.Object转为JsonArray(得保证obj是个Array数组,否则报错)
Object obj = map.get("TestArray"); JSONArray myJsonArray = JSONArray.fromObject(obj);
3.JsonArray转为List
List<String> arr = (List) myJsonArray;
4.List转为String[]
String[] arr2 = arr.toArray(new String[arr.size()]);
Java 类型转换String,List,Map,Array
标签:报错 nbsp div bsp 数组 sharp class 类型 object
原文地址:https://www.cnblogs.com/myyBlog/p/10265721.html