使用java的剧作家的应对API响应

发布于 2025-02-04 07:40:17 字数 168 浏览 2 评论 0原文

我正在探索剧作家自动进行API测试,但我无法使用Java的Pojo对剧作家的敏捷性。我曾经使用以下代码放心,以此来进行此操作:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

篱下浅笙歌 2025-02-11 07:40:17

我在ObjectMapper的帮助下设法做到了这一点。

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

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文