This happens because int is read back as decimal and cannot be converted to long.
This can be handled with small change to JSON.cs to check for decimal:
private object ChangeType(object value, Type conversionType)
{
if (conversionType == typeof(int))
{
string s = value as string;
if (s == null)
if (value is decimal dec)
return decimal.ToInt32(dec);
else
return (int)((long)value);
else if (_params.AutoConvertStringToNumbers)
return Helper.CreateInteger(s, 0, s.Length);
else
throw new Exception("AutoConvertStringToNumbers is disabled for converting string : " + value);
}
else if (conversionType == typeof(long))
{
string s = value as string;
if (s == null)
if (value is decimal dec)
return decimal.ToInt64(dec);
else
return (long)value;
else if (_params.AutoConvertStringToNumbers)
return Helper.CreateLong(s, 0, s.Length);
else
throw new Exception("AutoConvertStringToNumbers is disabled for converting string : " + value);
}
...
For some reason, serializing and deserializing generic collection of int or long, eg. List or int[] fails to be deserialized.
This happens because int is read back as decimal and cannot be converted to long.
This can be handled with small change to JSON.cs to check for decimal:
Or did I miss something?