Exemplo n.º 1
0
        public override decimal?Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            if (reader.TokenType == JsonTokenType.String)
            {
                string stringValue = reader.GetString();
                if (decimal.TryParse(stringValue, out decimal value))
                {
                    return(value);
                }
            }
            else if (reader.TokenType == JsonTokenType.Number)
            {
                return(reader.GetDecimal());
            }

            throw new JsonException();
        }