How to serialize an array with custom properties in Java script?

I want to create a class in javascript like so:

class pClass extends System.Object {
var f = 0;
var g = 0;
var h = 0;
var d = "";
var parent : Vector2;
}

@SerializeField
var grid : Vector2[];

grid = new Vector2[70000];

function init (grid) {
    var n : int = 0;
    for(var x = 0; x < gridSizeX; x++) {
        for(var y = 0; y < gridSizeY; y++) {
            grid[n] = pClass();
            grid[n] = Vector2(x,y);
            grid[n].f = 0;
            grid[n].g = 0;
            grid[n].h = 0;
            grid[n].d = "";
            grid[n].parent = Vector2(-1,-1);
            n++;
        }   
    }
}

The code compiles fine, but when I try and run it I get:

InvalidCastException: Cannot cast from source type to destination type.

Is there any way of making this work?

`grid[n] = pClass();` both doesn't make sense and is useless in your code. You need to decide what grid actually is, in terms of data type.