mirror of
https://github.com/Tribufu/TribufuDotNet
synced 2026-08-08 12:21:07 +00:00
22 lines
642 B
C#
22 lines
642 B
C#
// Copyright (c) Tribufu. All Rights Reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
using System;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Tribufu.Serialization
|
|
{
|
|
public class DecimalStringConverter : JsonConverter<decimal>
|
|
{
|
|
public override decimal Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
{
|
|
return Convert.ToUInt64(reader.GetString());
|
|
}
|
|
|
|
public override void Write(Utf8JsonWriter writer, decimal value, JsonSerializerOptions options)
|
|
{
|
|
writer.WriteStringValue(value.ToString());
|
|
}
|
|
}
|
|
}
|