package org.opentripplanner.model.json_serialization;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.util.BitSet;

/**
 * Serialize a BitSet to an array [true, false . . .].
 */
public class BitSetSerializer extends JsonSerializer<BitSet> {

    @Override public void serialize(BitSet bitSet, JsonGenerator jsonGenerator,
            SerializerProvider serializerProvider) throws IOException, JsonProcessingException {

        jsonGenerator.writeStartArray();

        for (int i = 0; i < bitSet.cardinality(); i++) {
            jsonGenerator.writeBoolean(bitSet.get(i));
        }

        jsonGenerator.writeEndArray();
    }
}

@@ -709,19 +709,14 @@
 Set.
-cardinality
+length
 (); 

use bitset.length to get length, fixes #2146