From 4340b1899470c06f170817dbc1200040619fbf8d Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Sat, 14 Oct 2023 23:19:25 +0200 Subject: Handle floats etc in requests --- LibMatrix/StateEvent.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'LibMatrix/StateEvent.cs') 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); -- cgit 1.4.1