Example usage for com.fasterxml.jackson.core.json JsonWriteContext STATUS_EXPECT_VALUE

List of usage examples for com.fasterxml.jackson.core.json JsonWriteContext STATUS_EXPECT_VALUE

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core.json JsonWriteContext STATUS_EXPECT_VALUE.

Prototype

int STATUS_EXPECT_VALUE

To view the source code for com.fasterxml.jackson.core.json JsonWriteContext STATUS_EXPECT_VALUE.

Click Source Link

Usage

From source file:com.ning.billing.recurly.model.jackson.RecurlyObjectsSerializer.java

@Override
public void serialize(final T values, final JsonGenerator jgen, final SerializerProvider provider)
        throws IOException {
    if (values.isEmpty()) {
        jgen.writeStartArray();//  w w  w .  j  a va2  s.co  m
        jgen.writeEndArray();
        return;
    }

    final ToXmlGenerator xmlgen = (ToXmlGenerator) jgen;
    // Nested RecurlyObjects
    final boolean shouldSkipWritingFieldName = xmlgen.getOutputContext()
            .writeFieldName(elementName) == JsonWriteContext.STATUS_EXPECT_VALUE;
    boolean firstValue = true;
    for (final U value : values) {
        if (!shouldSkipWritingFieldName && firstValue) {
            xmlgen.setNextName(new QName(null, elementName));
        } else if (!shouldSkipWritingFieldName) {
            xmlgen.writeFieldName(elementName);
        }
        firstValue = false;

        xmlgen.writeObject(value);
    }
}

From source file:com.bazaarvoice.jackson.rison.RisonGenerator.java

@Override
public void writeFieldName(String name) throws IOException, JsonGenerationException {
    int status = _writeContext.writeFieldName(name);
    if (status == JsonWriteContext.STATUS_EXPECT_VALUE) {
        _reportError("Can not write a field name, expecting a value");
    }//from  www .jav a  2s  .  c  om
    _writeFieldName(name, (status == JsonWriteContext.STATUS_OK_AFTER_COMMA));
}

From source file:com.bazaarvoice.jackson.rison.RisonGenerator.java

@Override
public void writeFieldName(SerializableString name) throws IOException, JsonGenerationException {
    // Object is a value, need to verify it's allowed
    int status = _writeContext.writeFieldName(name.getValue());
    if (status == JsonWriteContext.STATUS_EXPECT_VALUE) {
        _reportError("Can not write a field name, expecting a value");
    }/*from   w w w . j av  a  2  s  .co m*/
    _writeFieldName(name, (status == JsonWriteContext.STATUS_OK_AFTER_COMMA));
}

From source file:de.undercouch.bson4jackson.BsonGenerator.java

@Override
public void writeFieldName(String name) throws IOException, JsonGenerationException {
    int status = _writeContext.writeFieldName(name);
    if (status == JsonWriteContext.STATUS_EXPECT_VALUE) {
        _reportError("Can not write a field name, expecting a value");
    }// w  w w  .  j a  va 2s  .c  om
    _writeFieldName(name);
}