All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hydraql.shaded.fastjson2.writer.ObjectWriterImplMapEntry Maven / Gradle / Ivy

The newest version!
package hydraql.shaded.fastjson2.writer;

import hydraql.shaded.fastjson2.JSONWriter;

import java.lang.reflect.Type;
import java.util.Map;

final class ObjectWriterImplMapEntry
        extends ObjectWriterBaseModule.PrimitiveImpl {
    static final ObjectWriterImplMapEntry INSTANCE = new ObjectWriterImplMapEntry();

    @Override
    public void writeJSONB(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features) {
        Map.Entry entry = (Map.Entry) object;
        if (entry == null) {
            jsonWriter.writeNull();
            return;
        }

        jsonWriter.startArray(2);
        jsonWriter.writeAny(entry.getKey());
        jsonWriter.writeAny(entry.getValue());
    }

    @Override
    public void write(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features) {
        Map.Entry entry = (Map.Entry) object;
        if (entry == null) {
            jsonWriter.writeNull();
            return;
        }

        jsonWriter.startObject();
        jsonWriter.writeAny(entry.getKey());
        jsonWriter.writeColon();
        jsonWriter.writeAny(entry.getValue());
        jsonWriter.endObject();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy