mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 14:20:29 +01:00
Exchange json serializer #438
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 @LadislavPataki on GitHub (Aug 11, 2022).
Is there a possibility to exchange the json serializer from Json.NET to System.Text.Json? I would like to use BodyAsJson method to create response or at least extend it somehow. Could you help me with that? Thanks.
@StefH commented on GitHub (Aug 12, 2022):
This will be difficult because Newtonsoft is also used for replacing values in json using templating.
But it depends on how exactly you want to use
BodyAsJsonand what you expect from it. Maybe adding a optional parameter to that method to indicate that you want to use System.Text.Json?@LadislavPataki commented on GitHub (Aug 12, 2022):
That would be sufficient. But this way I would have to pass the serializer options every time. For now I'm using an extension method. I was just wondering if it's even possible. Thanks for your reply.
@StefH commented on GitHub (Aug 12, 2022):
Can you provide that extension method?
@LadislavPataki commented on GitHub (Aug 12, 2022):
The extension method.
Usage:
@StefH commented on GitHub (Aug 14, 2022):
I see. I'll check if this can be added.
Note that I also started a new project https://github.com/StefH/JsonConverter which could maybe solve these issues.
@StefH commented on GitHub (Aug 15, 2022):
@LadislavPataki
See this preview version (
1.5.3-ci-16370) where you can provide a different JsonConverter when usingWithBody:For implementations for IJsonConverter, see https://github.com/StefH/JsonConverter.
(how to install preview version: see https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions)
@StefH commented on GitHub (Aug 17, 2022):
@LadislavPataki
Did you have time to test this?
@LadislavPataki commented on GitHub (Aug 18, 2022):
Hi @StefH , I'm sorry I didn't have time for this. I'll give it a try at the weekend.
@StefH commented on GitHub (Aug 23, 2022):
@LadislavPataki
Did you already have time to test it?
@LadislavPataki commented on GitHub (Aug 23, 2022):
Hi @StefH, I'm not able to find version (1.5.3-ci-16370). Am I doing something wrong?
@StefH commented on GitHub (Aug 23, 2022):
That version is already deleted I think.
Please try this one:
1.5.3-ci-16393
@LadislavPataki commented on GitHub (Aug 23, 2022):
Thanks, the Decorator looks fine to me. This way you can exchange the Converters easily.
@StefH commented on GitHub (Aug 23, 2022):
Yes
For all implementations, see https://github.com/StefH/JsonConverter
I'll close it this and release a new official NuGet soon.