.NET core JsonSerializer incorrectly serializes UTF8 characters

Instead of writing the UTF8 characters, the serializes uses the UTF8 code values instead. 
To avoid this, use the following:


var options = new JsonSerializerOptions
{
	Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
	WriteIndented = true
};

var serialized = JsonSerializer.Serialize(someObject, options);

Post a Comment

Previous Post Next Post