# 数据的拼装问题，，无从下手

0

1

[{2017,20},{2017,22}{2017,25}{2017,26}{2017,28}，{2018,20}{2018,21}]

0
``` 1     public static void main(String[] args) {
2         Object[] A = new Object[1];
3         A[0]= "{2017,20},{2017,22}{2017,25}{2017,26}{2017,28},{2018,20}{2018,21}";
4         String regex = (String)A[0];
5         String[] date = regex.split("\\},\\{|\\}\\{|\\{|\\}");
6         List<String> seventeen = new ArrayList<String>();
7         List<String> eighteen = new ArrayList<String>();
8         for(int i =0;i<date.length;i++) {
9             if(date[i].contains("2017")) {
10                 String[] day = date[i].split(",");
12             }
13             if(date[i].contains("2018")) {
14                 String[] day = date[i].split(",");
16             }
17         }
18         StringBuffer seventeenSB = new StringBuffer("2017:[");
19         seventeen.forEach(e -> {
20             seventeenSB.append("'"+e+"',");
21         });
22         StringBuffer eighteenSB = new StringBuffer("2018:[");
23         eighteen.forEach(e -> {
24             eighteenSB.append("'"+e+"',");
25         });
26         seventeenSB.delete(seventeenSB.length()-1, seventeenSB.length());
27         eighteenSB.delete(eighteenSB.length()-1, eighteenSB.length());
28         seventeenSB.append(']');
29         eighteenSB.append(']');
30         String str = new String("{"+seventeenSB+","+eighteenSB+"}");
31         System.out.println(str);
32     }```

0

js数组？

您需要登录以后才能回答，未注册用户请先注册