Search code examples
c#.net-standard

Alternative to JsonSerializer.SerializeToUtf8Bytes in .NET Standard


JsonSerializer is part of System.Text.Json namespace of .NET Core & .NET 5. Unfortunately it's unavailable in .NET Standard.

Is there any alternative to JsonSerializer.SerializeToUtf8Bytes method available in .NET Standard?


Solution

  • This seems to be alternative:

    Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(message))