I'm writing a custom json serializer based on System.Text.Json
, reading utf-8 string from array. In the examples I have found a following code:
string propertyName = reader.GetString();
if (propertyName != "TypeDiscriminator") {
throw new JsonException();
}
Surely I'm not interested in allocating propertyName
variable, especially if it is such long. It will be thrown away after the name is found equal to the expected literal string.
Is there any possibility to do this check without actually getting a string instance?