about summary refs log tree commit diff
path: root/LibMatrix/StateEvent.cs
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-10-14 23:19:25 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-10-14 23:19:25 +0200
commit4340b1899470c06f170817dbc1200040619fbf8d (patch)
treed1d6049d7bc8185c4222238a49846f964bfa7848 /LibMatrix/StateEvent.cs
parentError handling (diff)
downloadLibMatrix-4340b1899470c06f170817dbc1200040619fbf8d.tar.xz
Handle floats etc in requests
Diffstat (limited to 'LibMatrix/StateEvent.cs')
-rw-r--r--LibMatrix/StateEvent.cs8
1 files changed, 7 insertions, 1 deletions
diff --git a/LibMatrix/StateEvent.cs b/LibMatrix/StateEvent.cs
index e846811..fb4dd71 100644
--- a/LibMatrix/StateEvent.cs
+++ b/LibMatrix/StateEvent.cs
@@ -5,6 +5,7 @@ using System.Text.Json.Serialization;
 using ArcaneLibs;
 using ArcaneLibs.Extensions;
 using LibMatrix.EventTypes;
+using LibMatrix.Extensions;
 using LibMatrix.Interfaces;
 
 namespace LibMatrix;
@@ -41,7 +42,12 @@ public class StateEvent {
                 return null!;
             }
             try {
-                return (EventContent)RawContent.Deserialize(GetType)!;
+                var jse = new JsonSerializerOptions();
+                jse ??= new JsonSerializerOptions();
+                jse.Converters.Add(new JsonFloatStringConverter());
+                jse.Converters.Add(new JsonDoubleStringConverter());
+                jse.Converters.Add(new JsonDecimalStringConverter());
+                return (EventContent)RawContent.Deserialize(GetType, jse)!;
             }
             catch (JsonException e) {
                 Console.WriteLine(e);