How to filter in BodyAsFile JsonPath.SelectToken #373

Closed
opened 2025-12-29 15:22:12 +01:00 by adam · 1 comment
Owner

Originally created by @AndresGMD on GitHub (Oct 20, 2021).

Similar as Body As Json:

      "BodyAsJson": {
        "method": "{{request.method}}",
        "response": "{{JsonPath.SelectToken request.body \"$.person[?(@.id == 1)]\"}}"
      },

How to use in Body As File ??

      "BodyAsFile": {
        "method": "{{request.method}}",
        "response": "{{JsonPath.SelectToken {{Path/to/Json_file}}\"$.person[?(@.id == 1)]\"}}"
      },

This feature is supported?

Thanks in Advance

Originally created by @AndresGMD on GitHub (Oct 20, 2021). Similar as Body As Json: ``` "BodyAsJson": { "method": "{{request.method}}", "response": "{{JsonPath.SelectToken request.body \"$.person[?(@.id == 1)]\"}}" }, ``` How to use in Body As File ?? ``` "BodyAsFile": { "method": "{{request.method}}", "response": "{{JsonPath.SelectToken {{Path/to/Json_file}}\"$.person[?(@.id == 1)]\"}}" }, ``` This feature is supported? Thanks in Advance
adam added the question label 2025-12-29 15:22:12 +01:00
adam closed this issue 2025-12-29 15:22:12 +01:00
Author
Owner

@StefH commented on GitHub (Oct 21, 2021):

Hello @andresendava,

For your scenario, you need to set UseTransformer to true to also transform the filename.

More details how to use it are found here:

@StefH commented on GitHub (Oct 21, 2021): Hello @andresendava, For your scenario, you need to set UseTransformer to true to also transform the filename. More details how to use it are found here: - https://github.com/WireMock-Net/WireMock.Net/blob/dc078b57ea463e2c9c7da7f6579af34000596446/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithTransformerTests.cs#L417 - https://github.com/WireMock-Net/WireMock.Net/blob/dc078b57ea463e2c9c7da7f6579af34000596446/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithHandlebarsJsonPathTests.cs#L352
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#373