Java Code Examples for org.codehaus.jackson.JsonGenerator#writeObjectField()

The following examples show how to use org.codehaus.jackson.JsonGenerator#writeObjectField() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobViewSerialiser.java    From jenkins-build-monitor-plugin with MIT License 6 votes vote down vote up
@Override
public void serialize(JobView job, JsonGenerator jgen, SerializerProvider provider) throws IOException {
    jgen.writeStartObject();
    jgen.writeObjectField("name",               job.name());
    jgen.writeObjectField("url",                job.url());
    jgen.writeObjectField("status",             job.status());
    jgen.writeObjectField("hashCode",           job.hashCode());
    jgen.writeObjectField("progress",           job.progress());
    jgen.writeObjectField("estimatedDuration",  job.estimatedDuration());

    for (Feature<?> feature : job.features()) {
        Object serialised = feature.asJson();

        if (serialised != null) {
            jgen.writeObjectField(nameOf(serialised), serialised);
        }
    }

    jgen.writeEndObject();
}
 
Example 2
Source File: RecordWithMetadataToEnvelopedRecordWithMetadata.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
private void writeRecord(RecordWithMetadata<?> inputRecord, JsonGenerator generator)
    throws IOException {
  if (shouldInterpretRecordAsUtf8ByteArray(inputRecord)) {
    generator.writeFieldName("r");
    byte[] bytes = (byte[]) inputRecord.getRecord();
    generator.writeUTF8String(bytes, 0, bytes.length);
  } else {
    generator.writeObjectField("r", inputRecord.getRecord());
  }
}
 
Example 3
Source File: RecordWithMetadataToEnvelopedRecordWithMetadata.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
private void writeHeaders(RecordWithMetadata<?> inputRecord, JsonGenerator generator)
    throws IOException {
  generator.writeStringField("mId", inputRecord.getMetadata().getGlobalMetadata().getId());

  if (!inputRecord.getMetadata().getRecordMetadata().isEmpty()) {
    generator.writeObjectField("rMd", inputRecord.getMetadata().getRecordMetadata());
  }
}
 
Example 4
Source File: GlobalMetadata.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
/**
 * Write this object out to an existing JSON stream
 */
protected void bodyToJsonUtf8(JsonGenerator generator)
    throws IOException {

  generator.writeObjectField("dataset", datasetLevel);
  generator.writeObjectFieldStart("file");
  for (Map.Entry<String, Map<String, Object>> entry : fileLevel.entrySet()) {
    generator.writeObjectField(entry.getKey(), entry.getValue());
  }
  generator.writeEndObject();

}