Skip to content

System.Text.Json - json formatter #128

Closed

Description

@djgrech

Does this library support System.Text.Json serialization out of the box? Or is there a way how to use System.Text.Json it instead of Newtonsoft

Thank you

Activity

  1. self-assigned this
    on Jul 30, 2024
  2. added this to the 4.4.x milestone on Jul 30, 2024
  3. Pathoschild commented on Jul 30, 2024

    @Pathoschild
    Owner

    Hi! The fluent client uses the same formatters as .NET's built-in HttpClient by default (i.e. Newtonsoft).

    You can easily change the format like this:

    client.Formatters.Remove(client.Formatters.JsonFormatter);
    client.Formatters.Add(new ...());

    .NET doesn't seem to have an official media type formatter using System.Text.Json yet, but you could try searching NuGet for third-party implementations or create your own.

    That said, note that System.Text.Json is much stricter than Newtonsoft.Json. While that results in better performance, it will also throw an exception at the slightest deviation from the strict JSON spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions