add option to disable null fields in the result of toArray()