adding toJSON for arrays