收银端库存列表,商品列表
This commit is contained in:
@@ -5,11 +5,14 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
@@ -23,6 +26,27 @@ public class ListUtil {
|
||||
|
||||
}
|
||||
|
||||
public static List<String> stringChangeStringList(String listString){
|
||||
// 使用Fastjson将JSON字符串转换为JSONArray对象
|
||||
|
||||
listString = listString.replaceAll("\"", "").replaceAll("\\[", "").replaceAll("\\]", "");
|
||||
List<String> stringList = Stream.of(listString.split(","))
|
||||
.map(String::trim)
|
||||
.collect(Collectors.toList());
|
||||
return stringList;
|
||||
}
|
||||
|
||||
public static List<Integer> stringChangeIntegerList(List<String> listString){
|
||||
|
||||
// method1 创建一个Integer类型的集合,循环遍历String类型的数组并把数据添加进集合
|
||||
List<Integer> integerList = new ArrayList<>();
|
||||
for (String s : listString) {
|
||||
integerList.add(Integer.parseInt(s));
|
||||
}
|
||||
System.out.println(integerList);
|
||||
return integerList;
|
||||
// return listString.stream()
|
||||
// .map(Integer::valueOf)
|
||||
// .collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user