【问题标题】:Is there any way to convert the Reponse JSON to Pact body format?有什么办法可以将 Response JSON 转换为 Pact body 格式吗?
【发布时间】:2022-11-25 13:33:43
【问题描述】:

在生成 Contract 时,我们需要在 Pact 主体中输入响应 JSON 属性。一些 Response JSON 中的属性列表有 1000+,在这种情况下,手动输入细节到 Pact body 是不可能的。

是否有任何工具可以将 Response JSON 转换为 Pact 正文格式?还有其他解决方案吗?

【问题讨论】:

    标签: pact


    【解决方案1】:

    是的,可以使用 Jackson 库将 Java 对象转换为 JSON:

    ObjectMapper obm = new ObjectMapper(); 
    String ActualJson = obm.writeValueAsString("Object obj"). 
    

    【讨论】:

      猜你喜欢
      • 2015-07-26
      • 2012-05-03
      • 1970-01-01
      • 2022-07-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-04
      • 1970-01-01
      相关资源
      最近更新 更多