javaapideserializationplaywrightplaywright-java

Deserialise API Response of PlayWright using Java


I am exploring playwright for automating api tests and I am unable to deserialise APIResponse of playwright to a POJO using java. I used to do this with rest assured using following code:

        PetStoreModel petStoreModel =  response.as(PetStoreModel.class);

Solution

  • I managed to do this with the help of ObjectMapper.

    APIResponse response = getPetStoreResponse();
    ObjectMapper objectMapper = new ObjectMapper();
    PetStoreModel petStoreModel = objectMapper.readValue(response.text(),PetModel.class);