Skip to content
Advertisement

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);

Advertisement

Answer

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);
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement