一、JSON格式
{"code":"200","msg":"success","data":["Yinqing","ArtCreativity"]}
二、json格式转为List集合代码
@Test public void test() { String post = "{\"code\":\"200\",\"msg\":\"success\",\"data\":[\"Yinqing\",\"ArtCreativity\"]}"; // 方法1[常用]:获取data中的数据转为List List<String> stringList1 = JSON.parseObject(post).getJSONArray("data").toJavaList(String.class); System.out.println("stringList1 = " + stringList1); // 方法2:获取data中的数据转为List String data = JSON.parseObject(post).getString("data"); List<String> stringList2 = JSON.parseArray(data, String.class); System.out.println("stringList2 = " + stringList2); }
标签:String,转为,List,JSON,stringList2,json,格式,data From: https://www.cnblogs.com/saoge/p/16592248.html