Fix handling of enumerables when serializing to json