[Java]String和List转换

  1. 将json串转为list
String blackUids = "[1,2,3,4]";
List ids = JSONObject.parseArray(blackUids, Long.class);
  1. 将逗号分隔字符串转为list
List uids = Arrays.asList(blackListUids.split(",")).stream().map(uid -> NumberUtils.toLong(uid)).collect(Collectors.toList());
  1. 将字符串转为数组
String[] skuIds = skuLevelBonusMergeDTO.getSkuIds().split(",")
  1. 待续

你可能感兴趣的:(java)