Example usage for com.fasterxml.jackson.core JsonGenerator writeString

List of usage examples for com.fasterxml.jackson.core JsonGenerator writeString

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonGenerator writeString.

Prototype

public abstract void writeString(SerializableString text) throws IOException, JsonGenerationException;

Source Link

Document

Method similar to #writeString(String) , but that takes SerializableString which can make this potentially more efficient to call as generator may be able to reuse quoted and/or encoded representation.

Usage

From source file:com.cedarsoft.serialization.serializers.jackson.DateTimeSerializer.java

@Override
public void serialize(@Nonnull JsonGenerator serializeTo, @Nonnull DateTime object,
        @Nonnull Version formatVersion) throws IOException, VersionException, JsonProcessingException {
    serializeTo.writeString(createFormatter().print(object));
}

From source file:org.omg.dmn.tck.marshaller._20160719.json.ValueSerializer.java

@Override
public void serialize(Object value, JsonGenerator gen, SerializerProvider serializers)
        throws IOException, JsonProcessingException {
    if (value instanceof Element) {
        String content = ((Element) value).getTextContent();
        gen.writeString(content);
    } else {/*  w  ww . j  a va2  s  .c o m*/
        gen.writeObject(value);
    }
}

From source file:org.opendaylight.ovsdb.lib.notation.json.UUIDSerializer.java

@Override
public void serialize(UUID value, JsonGenerator generator, SerializerProvider provider)
        throws IOException, JsonProcessingException {
    generator.writeStartArray();/*w ww.  ja  v a2 s .  co  m*/
    try {
        java.util.UUID.fromString(value.toString());
        generator.writeString("uuid");
    } catch (IllegalArgumentException ex) {
        generator.writeString("named-uuid");
    }
    generator.writeString(value.toString());
    generator.writeEndArray();
}

From source file:com.cedarsoft.serialization.serializers.jackson.VersionSerializer.java

@Override
public void serialize(@Nonnull JsonGenerator serializeTo, @Nonnull Version object,
        @Nonnull Version formatVersion) throws IOException, JsonProcessingException {
    verifyVersionReadable(formatVersion);
    serializeTo.writeString(object.format());
}

From source file:com.cedarsoft.serialization.serializers.jackson.BaseNameSerializer.java

@Override
public void serialize(@Nonnull JsonGenerator serializeTo, @Nonnull BaseName object,
        @Nonnull Version formatVersion) throws IOException, JsonProcessingException {
    verifyVersionReadable(formatVersion);
    serializeTo.writeString(object.getName());
}

From source file:com.cedarsoft.serialization.serializers.jackson.UrlSerializer.java

@Override
public void serialize(@Nonnull JsonGenerator serializeTo, @Nonnull URL object, @Nonnull Version formatVersion)
        throws IOException, JsonProcessingException {
    verifyVersionWritable(formatVersion);
    serializeTo.writeString(object.toString());
}

From source file:com.google.openrtb.json.AbstractOpenRtbJsonWriter.java

/**
 * Writes a string that represents a ContentCategory's JSON name, returning success status.
 * If the factory is in strict mode, the category name is validated.
 *///from ww  w .  ja  v  a 2  s .com
protected final boolean writeContentCategory(String cat, JsonGenerator gen) throws IOException {
    if (!factory.isStrict() || OpenRtbUtils.categoryFromName(cat) != null) {
        gen.writeString(cat);
        return true;
    } else {
        return false;
    }
}

From source file:org.commonjava.maven.atlas.ident.jackson.ProjectRefSerializer.java

@Override
public void serialize(final T src, final JsonGenerator generator, final SerializerProvider provider)
        throws IOException, JsonGenerationException {
    if (keySer) {
        generator.writeFieldName(src.toString());
    } else {/*from   ww w. j av  a  2  s  . c o m*/
        generator.writeString(src.toString());
    }
}

From source file:org.kiji.rest.serializers.KijiRestEntityIdToJson.java

/**
 * {@inheritDoc}//from  w ww . j  av  a2 s.co m
 */
@Override
public void serialize(KijiRestEntityId record, JsonGenerator generator, SerializerProvider provider)
        throws IOException {
    if (record.hasComponents()) {
        generator.writeTree(record.getJsonEntityId());
    } else {
        generator.writeString(record.getStringEntityId());
    }
}

From source file:org.jobscheduler.dashboard.domain.LogSerializer.java

@Override
public void serialize(byte[] bytes, JsonGenerator jgen, SerializerProvider provider)
        throws IOException, JsonProcessingException {
    jgen.writeStartArray();/* www. j a  v  a 2  s.c o m*/
    try {
        SOSStreamUnzip unzip = new SOSStreamUnzip(bytes);
        jgen.writeString(StringEscapeUtils.escapeHtml(unzip.unzip2String()));
    } catch (Exception e) {
        jgen.writeString("No log");
    }
    jgen.writeEndArray();

}