亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法反序列化 Wiremock Json 文件配置中收到的 START_ARRAY 令牌異常中的

無法反序列化 Wiremock Json 文件配置中收到的 START_ARRAY 令牌異常中的

烙印99 2023-08-16 17:55:56
WireMock我正在嘗試使用帶有文件配置的獨立 jar來模擬一些 API JSON。下面是JSON包含我正在使用的多個存根映射的文件-{  "mappings": [{      "request": {        "method": "GET",        "url": "/users"      },      "response": {        "status": 200,        "body": [{            "id": 1,            "name": "Leanne Graham",            "username": "Bret",            "email": "[email protected]",            "address": {              "street": "Kulas Light",              "suite": "Apt. 556",              "city": "Gwenborough",              "zipcode": "92998-3874",              "geo": {                "lat": "-37.3159",                "lng": "81.1496"              }            },            "phone": "1-770-736-8031 x56442",            "website": "hildegard.org",            "company": {              "name": "Romaguera-Crona",              "catchPhrase": "Multi-layered client-server neural-net",              "bs": "harness real-time e-markets"            }          },          {            "id": 2,            "name": "Ervin Howell",            "username": "Antonette",            "email": "[email protected]",            "address": {              "street": "Victor Plains",              "suite": "Suite 879",              "city": "Wisokyburgh",              "zipcode": "90566-7771",              "geo": {                "lat": "-43.9509",                "lng": "-34.4618"              }            },            "phone": "010-692-6593 x09125",            "website": "anastasia.net",            "company": {              "name": "Deckow-Crist",              "catchPhrase": "Proactive didactic contingency",              "bs": "synergize scalable supply-chains"            }          }        ],        "headers": {          "Content-Type": "application/json"        }      }    },    {      "request": {        "method": "GET",        "url": "/posts?userId=1"      },      "response": {        "status": 200,        "body": "[]"      }    }當我嘗試Wiremock使用獨立 jar ( wiremock-standalone-2.24.1.jar) 啟動服務器時,出現以下異常,我驗證了 Json 架構,它看起來沒問題。
查看完整描述

3 回答

?
偶然的你

TA貢獻1841條經驗 獲得超3個贊

響應定義中的正文可以是body,?jsonBody,base64Bodynull


查看完整回答
反對 回復 2023-08-16
?
至尊寶的傳說

TA貢獻1789條經驗 獲得超10個贊

body參數始終需要 WireMock 中的字符串。一旦我將我的響應作為字符串傳遞到正文中,它就起作用了。



查看完整回答
反對 回復 2023-08-16
?
智慧大石

TA貢獻1946條經驗 獲得超3個贊

對象“ response ”中的鍵“ body ”僅接受字符串。如果您想向其傳遞 JSON,可以將鍵“ body ”替換為鍵“ jsonBody ”。



查看完整回答
反對 回復 2023-08-16
  • 3 回答
  • 0 關注
  • 205 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號