本文整理汇总了Java中org.codehaus.jackson.JsonGenerator.writeBoolean方法的典型用法代码示例。如果您正苦于以下问题:Java JsonGenerator.writeBoolean方法的具体用法?Java JsonGenerator.writeBoolean怎么用?Java JsonGenerator.writeBoolean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.jackson.JsonGenerator
的用法示例。
在下文中一共展示了JsonGenerator.writeBoolean方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeObject
import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
private void writeObject(JsonGenerator jg, Object value) throws IOException {
if(value == null) {
jg.writeNull();
} else {
Class<?> c = value.getClass();
if (c.isArray()) {
jg.writeStartArray();
int len = Array.getLength(value);
for (int j = 0; j < len; j++) {
Object item = Array.get(value, j);
writeObject(jg, item);
}
jg.writeEndArray();
} else if(value instanceof Number) {
Number n = (Number)value;
jg.writeNumber(n.toString());
} else if(value instanceof Boolean) {
Boolean b = (Boolean)value;
jg.writeBoolean(b);
} else if(value instanceof CompositeData) {
CompositeData cds = (CompositeData)value;
CompositeType comp = cds.getCompositeType();
Set<String> keys = comp.keySet();
jg.writeStartObject();
for(String key: keys) {
writeAttribute(jg, key, cds.get(key));
}
jg.writeEndObject();
} else if(value instanceof TabularData) {
TabularData tds = (TabularData)value;
jg.writeStartArray();
for(Object entry : tds.values()) {
writeObject(jg, entry);
}
jg.writeEndArray();
} else {
jg.writeString(value.toString());
}
}
}
示例2: writeObject
import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
private void writeObject(JsonGenerator jg, Object value) throws IOException {
if (value == null) {
jg.writeNull();
} else {
Class<?> c = value.getClass();
if (c.isArray()) {
jg.writeStartArray();
int len = Array.getLength(value);
for (int j = 0; j < len; j++) {
Object item = Array.get(value, j);
writeObject(jg, item);
}
jg.writeEndArray();
} else if (value instanceof Number) {
Number n = (Number) value;
jg.writeNumber(n.toString());
} else if (value instanceof Boolean) {
Boolean b = (Boolean) value;
jg.writeBoolean(b);
} else if (value instanceof CompositeData) {
CompositeData cds = (CompositeData) value;
CompositeType comp = cds.getCompositeType();
Set<String> keys = comp.keySet();
jg.writeStartObject();
for (String key : keys) {
writeAttribute(jg, key, cds.get(key));
}
jg.writeEndObject();
} else if (value instanceof TabularData) {
TabularData tds = (TabularData) value;
jg.writeStartArray();
for (Object entry : tds.values()) {
writeObject(jg, entry);
}
jg.writeEndArray();
} else {
jg.writeString(value.toString());
}
}
}
示例3: writeObject
import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
private static void writeObject(final JsonGenerator jg, final boolean description, Object value)
throws IOException {
if(value == null) {
jg.writeNull();
} else {
Class<?> c = value.getClass();
if (c.isArray()) {
jg.writeStartArray();
int len = Array.getLength(value);
for (int j = 0; j < len; j++) {
Object item = Array.get(value, j);
writeObject(jg, description, item);
}
jg.writeEndArray();
} else if(value instanceof Number) {
Number n = (Number)value;
jg.writeNumber(n.toString());
} else if(value instanceof Boolean) {
Boolean b = (Boolean)value;
jg.writeBoolean(b);
} else if(value instanceof CompositeData) {
CompositeData cds = (CompositeData)value;
CompositeType comp = cds.getCompositeType();
Set<String> keys = comp.keySet();
jg.writeStartObject();
for (String key: keys) {
writeAttribute(jg, key, null, cds.get(key));
}
jg.writeEndObject();
} else if(value instanceof TabularData) {
TabularData tds = (TabularData)value;
jg.writeStartArray();
for(Object entry : tds.values()) {
writeObject(jg, description, entry);
}
jg.writeEndArray();
} else {
jg.writeString(value.toString());
}
}
}
示例4: writeValue
import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
/** Called to write value.*/
protected void writeValue(Schema fieldSchema, Object datum, JsonGenerator generator) throws IOException {
try {
switch (fieldSchema.getType()) {
case INT:
generator.writeNumber(((Number) datum).intValue());
break;
case LONG:
generator.writeNumber((Long) datum);
break;
case DOUBLE:
generator.writeNumber((Double) datum);
break;
case BOOLEAN:
generator.writeBoolean((Boolean) datum);
break;
case STRING:
generator.writeString(datum.toString());
break;
case BYTES:
writeBytes(datum, generator);
break;
case NULL:
generator.writeNull();
break;
case RECORD:
writeRecord((RecordSchema) fieldSchema, datum, generator);
break;
case ENUM:
writeEnum((EnumSchema) fieldSchema, (Enum) datum, generator);
break;
case ARRAY:
writeArray((ArraySchema) fieldSchema, (List) datum, generator);
break;
case MAP:
writeMap((MapSchema) fieldSchema, (Map) datum, generator);
break;
case UNION:
writeUnion((UnionSchema) fieldSchema, datum, generator);
break;
default:
error(fieldSchema, datum);
}
} catch (NullPointerException e) {
throw npe(e, " of "+ fieldSchema.getName());
}
}