How to convert JSON string into List of Java object?

前端 未结 9 2221
醉酒成梦
醉酒成梦 2020-12-01 12:12

This is my JSON Array :-

[ 
    {
        \"firstName\" : \"abc\",
        \"lastName\" : \"xyz\"
    }, 
    {
        \"firstName\" : \"pqr\",
        \"         


        
9条回答
  •  南笙
    南笙 (楼主)
    2020-12-01 12:40

    use below simple code, no need to use any library

    String list = "your_json_string";
    Gson gson = new Gson();                         
    Type listType = new TypeToken>() {}.getType();
    ArrayList users = new Gson().fromJson(list , listType);
    

提交回复
热议问题