Serializing and deserializing a ArrayList

I added the code from this thread and just ran the unit test program, with these new routines and a call to DoLucaPTest(), and got no failures. Can you provide a minimal example of the failing code? Was there some other data structure (like an ArrayList) involved?

EDIT: I see now that Darko is posting the problem. I (not unreasonably) assumed that the ‘this’ that Darko was referring to was the example code in this thread, though maybe some other code is involved. If there was some other code pattern involved, then I will need an example of the failure so that I can repro.

public class Pager
{
    public int ID { get; set; }
    public int RIC { get; set; }
    public string Name { get; set; }
    public string SerialNumber { get; set; }
}

    public static byte[] LucaP_Serialize(object data)
    {
        JToken json = JsonConverter.Serialize(data);
        string jsonString = json.ToString();
        byte[] jsonBytes = Encoding.UTF8.GetBytes(jsonString);
        return jsonBytes;
    }

    public static Pager LucaP_Deserialize(byte[] data)
    {
        if (data.Length > 0)
        {
            string byteString = Encoding.UTF8.GetString(data);
            Pager pager = (Pager)JsonConverter.DeserializeObject(byteString, typeof(Pager));
            return pager;
        }
        return null;
    }

    private static void DoLucaPTest()
    {
        var pager = new Pager
        {
            ID = 1,
            RIC = 2,
            Name = "foo",
            SerialNumber = "123",
        };

        var data = LucaP_Serialize(pager);
        var result = LucaP_Deserialize(data);

        if (result.ID != pager.ID ||
            result.RIC != pager.RIC ||
            result.Name != pager.Name ||
            result.SerialNumber != pager.SerialNumber)
        {
            throw new Exception("LucaP test failed");
        }
    }