In spring-boot 3.0, the response body in maping js...
# general
v
In spring-boot 3.0, the response body in maping json should be a json string instead of JSON? ex) https://github.com/caligula95/spring-booot-wiremock/blob/master/src/test/resources[…]ings/users_abcd_repos-9a898c4b-476e-4dcc-a7d0-80b19b8ea159.json In the above link body is composed of JSON string. we cannot define it in JSON instead of json string?Converting json into json string not that hard. but it’s bit difficult to read and really hard to understand nested jsons 🙂
l
Hi, could you use the
jsonBody
element which allows you to specify the body as json? https://wiremock.org/docs/stubbing/#specifying-the-response-body
v
Hi @Lee Turner Thanks a lot. How to specify XML response body in the json file? There are some legacy applications in my company still uses xml 🙂
l
I think you have two options. Use the body element and wrap your xml in a string or use the bodyFileName element where you can reference a separate file for the body contents. The file you reference can be any file type so you can reference an xml file directly
You could do the same with a json file if you wanted to instead of using the jsonBody element I mentioned in my first reply.