Search in sources :

Example 16 with SerializedString

use of com.fasterxml.jackson.core.io.SerializedString in project jackson-databind by FasterXML.

the class SequenceWriterTest method testSimpleNonArray.

public void testSimpleNonArray() throws Exception {
    StringWriter strw = new StringWriter();
    SequenceWriter w = WRITER.forType(Bean.class).writeValues(strw);
    w.write(new Bean(13)).write(new Bean(-6)).writeAll(new Bean[] { new Bean(3), new Bean(1) }).writeAll(Arrays.asList(new Bean(5), new Bean(7)));
    w.close();
    assertEquals(aposToQuotes("{'a':13}\n{'a':-6}\n{'a':3}\n{'a':1}\n{'a':5}\n{'a':7}"), strw.toString());
    strw = new StringWriter();
    JsonGenerator gen = WRITER.getFactory().createGenerator(strw);
    w = WRITER.withRootValueSeparator(new SerializedString("/")).writeValues(gen);
    w.write(new Bean(1)).write(new Bean(2));
    w.close();
    gen.close();
    assertEquals(aposToQuotes("{'a':1}/{'a':2}"), strw.toString());
}
Also used : SerializedString(com.fasterxml.jackson.core.io.SerializedString) StringWriter(java.io.StringWriter) JsonGenerator(com.fasterxml.jackson.core.JsonGenerator)

Example 17 with SerializedString

use of com.fasterxml.jackson.core.io.SerializedString in project jackson-databind by FasterXML.

the class ObjectIdWriter method construct.

/**
     * Factory method called by {@link com.fasterxml.jackson.databind.ser.std.BeanSerializerBase}
     * with the initial information based on standard settings for the type
     * for which serializer is being built.
     * 
     * @since 2.3
     */
public static ObjectIdWriter construct(JavaType idType, PropertyName propName, ObjectIdGenerator<?> generator, boolean alwaysAsId) {
    String simpleName = (propName == null) ? null : propName.getSimpleName();
    SerializableString serName = (simpleName == null) ? null : new SerializedString(simpleName);
    return new ObjectIdWriter(idType, serName, generator, null, alwaysAsId);
}
Also used : SerializedString(com.fasterxml.jackson.core.io.SerializedString) SerializableString(com.fasterxml.jackson.core.SerializableString) SerializedString(com.fasterxml.jackson.core.io.SerializedString) SerializableString(com.fasterxml.jackson.core.SerializableString)

Example 18 with SerializedString

use of com.fasterxml.jackson.core.io.SerializedString in project jackson-databind by FasterXML.

the class UnwrappingBeanPropertyWriter method rename.

@Override
public UnwrappingBeanPropertyWriter rename(NameTransformer transformer) {
    String oldName = _name.getValue();
    String newName = transformer.transform(oldName);
    // important: combine transformers:
    transformer = NameTransformer.chainedTransformer(transformer, _nameTransformer);
    return _new(transformer, new SerializedString(newName));
}
Also used : SerializedString(com.fasterxml.jackson.core.io.SerializedString) SerializedString(com.fasterxml.jackson.core.io.SerializedString)

Aggregations

SerializedString (com.fasterxml.jackson.core.io.SerializedString)18 SerializableString (com.fasterxml.jackson.core.SerializableString)3 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 RawValue (com.fasterxml.jackson.databind.util.RawValue)1 StringWriter (java.io.StringWriter)1 BigDecimal (java.math.BigDecimal)1 ByteBuffer (java.nio.ByteBuffer)1 Random (java.util.Random)1