1 List集合转成json字符串

//Java集合
        List<String> list = new ArrayList<String>();
        list.add("aa");
        list.add("bb");
        Gson gson = new Gson(); 
        String reslut = gson.toJson(list); 
        System.out.println(reslut);

2 json字符串转成List集合

1 Buy类中的属性 : Integer id; String name;
2 
3 String buyCodes = [{id : 2,name : "aaa"},{id : 3,name : "bbb"}];
4 
5 List<Buy> listBuy = gson.fromJson(buyCodes, new TypeToken<List<Buy>>() {}.getType());

 

 

 后续需要复杂的转换在更新.....

相关文章:

  • 2021-08-08
  • 2022-12-23
  • 2022-02-07
  • 2022-02-21
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2021-12-31
猜你喜欢
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2022-03-04
  • 2021-12-29
相关资源
相似解决方案