https://linen.dev logo
#general
Title
# general
v

Vadivel Murugan

12/09/2023, 8:31 PM
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

Lee Turner

12/10/2023, 9:01 AM
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

Vadivel Murugan

12/10/2023, 9:10 PM
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

Lee Turner

12/10/2023, 10:16 PM
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.
2 Views