From 7161bb7e52fca2d005a5fdba74cb86cb8cd3a531 Mon Sep 17 00:00:00 2001 From: Manuel Salvatori Date: Mon, 31 Mar 2025 11:48:13 +0100 Subject: [PATCH] Handle wrond data format for decimal values causing overflow exception --- LearnositySDK/Utils/JsonObjectFactory.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/LearnositySDK/Utils/JsonObjectFactory.cs b/LearnositySDK/Utils/JsonObjectFactory.cs index ea49762..22abbe5 100755 --- a/LearnositySDK/Utils/JsonObjectFactory.cs +++ b/LearnositySDK/Utils/JsonObjectFactory.cs @@ -5,6 +5,8 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System.IO; +using System.Numerics; +using System.Xml.Linq; namespace LearnositySDK.Utils { @@ -98,7 +100,14 @@ public static JsonObject fromJToken(JsonObject jsonObject, string key, JToken it jsonObject.set(key, (int)item); break; case JTokenType.Float: - jsonObject.set(key, (decimal)item); + try + { + jsonObject.set(key, (float) item); + } + catch (OverflowException) + { + jsonObject.set(key, float.MaxValue); + } break; case JTokenType.String: jsonObject.set(key, (string)item);