空值校验
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package cn.ysk.cashier.utils;
|
package cn.ysk.cashier.utils;
|
||||||
|
|
||||||
|
import com.alibaba.druid.util.StringUtils;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
@@ -65,7 +66,6 @@ public class ListUtil {
|
|||||||
|
|
||||||
public static List<String> stringChangeStringList(String listString){
|
public static List<String> stringChangeStringList(String listString){
|
||||||
// 使用Fastjson将JSON字符串转换为JSONArray对象
|
// 使用Fastjson将JSON字符串转换为JSONArray对象
|
||||||
|
|
||||||
listString = listString.replaceAll("\"", "").replaceAll("\\[", "").replaceAll("\\]", "");
|
listString = listString.replaceAll("\"", "").replaceAll("\\[", "").replaceAll("\\]", "");
|
||||||
List<String> stringList = Stream.of(listString.split(","))
|
List<String> stringList = Stream.of(listString.split(","))
|
||||||
.map(String::trim)
|
.map(String::trim)
|
||||||
@@ -75,8 +75,10 @@ public class ListUtil {
|
|||||||
|
|
||||||
public static List<Integer> stringChangeIntegerList(String listString){
|
public static List<Integer> stringChangeIntegerList(String listString){
|
||||||
// 使用Fastjson将JSON字符串转换为JSONArray对象
|
// 使用Fastjson将JSON字符串转换为JSONArray对象
|
||||||
|
|
||||||
listString = listString.replaceAll("\"", "").replaceAll("\\[", "").replaceAll("\\]", "");
|
listString = listString.replaceAll("\"", "").replaceAll("\\[", "").replaceAll("\\]", "");
|
||||||
|
if (StringUtils.isEmpty(listString)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
List<Integer> integerList = Stream.of(listString.split(","))
|
List<Integer> integerList = Stream.of(listString.split(","))
|
||||||
.map(Integer::valueOf)
|
.map(Integer::valueOf)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|||||||
Reference in New Issue
Block a user