Java利用gson,将字符串转化为list

  public static void main(String[] args) {
    String jsonString = "[1,2,3,4]";

    Gson gson = new Gson();
    Type type = new TypeToken<List<Integer>>() {
    }.getType();
    List<Integer> list = gson.fromJson(jsonString, type);
    System.out.println(list);

  }
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
    </dependency>
原文地址:https://www.cnblogs.com/dc-earl/p/13280824.html