-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cln: add JsonConverter for handling enum
Unlike Newtonsoft.Json, System.Text.Json does not respect EnumMemberAttribute. (see: dotnet/runtime#31081) This caused an issue when sending request to c-lightning, when you use System.Text.Json for serialization lib, and there is a enum value in the request field, the field will be serialized into an int, instead of a string. Thus causing RPC error. This commit fixes it by using `JsonStringEnumConverterEx` (which is taken from an issue comment of issue above).
- Loading branch information
1 parent
7c5fdbb
commit fa9a3b3
Showing
6 changed files
with
135 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/DotNetLightning.ClnRpc/SystemTextJsonConverterExtensions.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace DotNetLightning.ClnRpc.SystemTextJsonConverters | ||
|
||
open System.Text.Json | ||
|
||
open System.Runtime.CompilerServices | ||
open NBitcoin | ||
|
||
[<Extension; AbstractClass; Sealed>] | ||
type ClnSharpClientHelpers = | ||
[<Extension>] | ||
static member internal AddDNLJsonConverters | ||
( | ||
this: JsonSerializerOptions, | ||
n: Network | ||
) = | ||
this._AddDNLJsonConverters(n) | ||
DotNetLightning.ClnRpc.AddJsonConverters.addEnumConverters(this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters