mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
Format response field as decimal number instead of string when using JsonPath. #471
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @robertmircea on GitHub (Dec 2, 2022).
Originally assigned to: @StefH on GitHub.
I am using the following mapping JSON file:
Please note the following transformation expression for "reservedAmount" field in the response:
"reservedAmount": "{{JsonPath.SelectToken request.bodyAsJson \"price\"}}",The transformer generates the following json response given that I send the following request to Wiremock standalone server:
Response:
Two questions:
reservedAmountfield as JSON decimal number and not as a string?@StefH commented on GitHub (Dec 3, 2022):
@robertmircea
You don't need to use JsonPath.SelectToken, you can just access the properties from that
request.bodyAsJson.So:
@StefH commented on GitHub (Dec 4, 2022):
https://github.com/WireMock-Net/WireMock.Net/pull/858
@robertmircea commented on GitHub (Dec 5, 2022):
Your recommendation works but the price field is still formatted incorrectly as a string instead of a number and it uses a comma instead of a decimal dot:
@StefH commented on GitHub (Dec 7, 2022):
I'll take a look.
@StefH commented on GitHub (Dec 7, 2022):
@robertmircea
Can you try preview 1.5.12-ci-16802 ?
https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions
@robertmircea commented on GitHub (Dec 10, 2022):
It works! Looks good! Can you include the fix please in a nuget release?
@StefH commented on GitHub (Dec 11, 2022):
Yes
I will release a new nuget soon.