How to convert JSON string into List of Java object?

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

This is my JSON Array :-

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


        
9条回答
  •  无人及你
    2020-12-01 12:22

    For any one who looks for answer yet:

    1.Add jackson-databind library to your build tools like Gradle or Maven

    2.in your Codes:

     add:
                   ObjectMapper mapper = new ObjectMapper();
                   List studentList = new ArrayList<>();
    
                   studentList = Arrays.asList(mapper.readValue(jsonStringArray, Student[].class));
    

提交回复
热议问题