一、将List String转为 List Map
复制代码
1
2
3
4
5
6
7
8
9
10
11def ori = ["https://ea2518240ecba.jpg","https://a071c1bc4a228ea9o.jpg","https://2fbfd7777f1c8.jpg","https://f240d6ce832a4.jpg"] def map = []; for (int i=0; i<ori.size(); i++){ def res = [:]; res.put("imgUrl", ori[i]); map.add(res); } return map
二、将String转为List
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17def ids = "[10, 1, 9]" def l = Eval.me(ids) /* def ids = "[9,10,2]" ids = Eval.me(ids); def map = []; for(int i=0; i<ids.size(); i++){ map.add(ids[i]); } return map //结果:[9,10,2] */
最后
以上就是暴躁发夹最近收集整理的关于Groovy List To List的全部内容,更多相关Groovy内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复