You could always use one of these, link
Ball Cap Buddy:
The plastic Ball-Cap Buddy is easy to use for washing Ball-Caps in the washing machine or the top rack of the dishwasher. Use for standard, duck-billed hats and visors. An excellent way to store hats too. Made in U.S.A.