UnmarshalJSON should return an error for invalid types

Thanks @joelkek for spotting this.