InstanceFactory for ArrayList

Using Json Serializer, how do i create an instance factory for the ArrayList of Pixels?

Deseriaize:

  public static Matrix DeserializeMatrix(string data)
        {
            if (data.Length > 0)
            {
                Matrix matrix = (Matrix)JsonConverter.DeserializeObject(data, typeof(Matrix), CreateInstance);
                return matrix;
            }
            return null;
        }

Instance

  private static object CreateInstance(string instancePath, JToken token, Type baseType, string fieldName, int length)
        {
           
        }

Class

public class Matrix : Base
{
    public string Name { get; set; }
    public ArrayList Pixels { get; set; }
}

public struct Pixel
{
    public int Index;
    public byte Red;
    public byte Green;
    public byte Blue;
}

When the instance path (a path into your JSON) and the fieldName match the field in your json that you want to allocate, then return newMatrix[length]