diff --git a/src/Altinn.App.Core/Helpers/JsonHelper.cs b/src/Altinn.App.Core/Helpers/JsonHelper.cs index 147f8ee02..6b79d7e16 100644 --- a/src/Altinn.App.Core/Helpers/JsonHelper.cs +++ b/src/Altinn.App.Core/Helpers/JsonHelper.cs @@ -1,5 +1,6 @@ #nullable enable +using System.Numerics; using Altinn.App.Core.Features; using Altinn.Platform.Storage.Interface.Models; using Microsoft.Extensions.Logging; @@ -182,7 +183,13 @@ private static void FindDiff(Dictionary dict, JToken? old, JTok break; default: - dict.Add(prefix, current == null ? null : ((JValue)current).Value); + var convertedValue = (current as JValue)?.Value switch + { + // BigInteger is not supported in json, so try to reduce to decimal, if possible, or string if too big + BigInteger bigInt => bigInt <= new BigInteger(decimal.MaxValue) ? (decimal)bigInt : bigInt.ToString(System.Globalization.NumberFormatInfo.InvariantInfo), + _ => (current as JValue)?.Value + }; + dict.Add(prefix, convertedValue); break; } }