Skip to content

Property with Json as a string #772

Closed Answered by SimonCropp
OskarKlintrot asked this question in Q&A
Discussion options

You must be logged in to vote

how about this

    [ModuleInitializer]
    public static void ModuleInitializer() =>
        VerifierSettings.MemberConverter<SimpleDtoWithJson, string>(
            target => target.Json,
            (target, value) => JToken.Parse(target.Json).ToString(Formatting.Indented));

    [Fact]
    public Task WithConverterAndMemberConverter() =>
        Verify(
            new SimpleDtoWithJson
            {
                Id = 10,
                Json = "{firstName: 'John'}"
            });

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@OskarKlintrot
Comment options

@SimonCropp
Comment options

@OskarKlintrot
Comment options

Answer selected by OskarKlintrot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants