prune undefined values when converting an array to object, for #5