本文整理汇总了Java中com.fasterxml.jackson.core.JsonGenerator.writeNull方法的典型用法代码示例。如果您正苦于以下问题:Java JsonGenerator.writeNull方法的具体用法?Java JsonGenerator.writeNull怎么用?Java JsonGenerator.writeNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.core.JsonGenerator
的用法示例。
在下文中一共展示了JsonGenerator.writeNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(final DividendQualification value, final JsonGenerator gen, final SerializerProvider serializers) throws IOException {
if (value == null || value == DividendQualification.UNKNOWN) {
gen.writeNull();
return;
}
switch (value) {
case PARTIALLY_QUALIFIED_INCOME:
gen.writeString("P");
break;
case QUALIFIED_INCOME:
gen.writeString("Q");
break;
case UNQUALIFIED_INCOME:
gen.writeString("N");
break;
default:
gen.writeNull();
break;
}
}
示例2: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(final TradingStatusType value, final JsonGenerator gen, final SerializerProvider serializers) throws IOException {
if (value == null || value == TradingStatusType.UNKNOWN) {
gen.writeNull();
return;
}
switch (value) {
case TRADING_HALTED:
gen.writeString("H");
break;
case TRADING_HALT_RELEASED_INTO_ORDER_ACCEPTANCE_PERIOD:
gen.writeString("O");
break;
case TRADING_PAUSED_AND_ORDER_ACCEPTANCE_PERIOD_ON_IEX:
gen.writeString("P");
break;
case TRADING_ON_IEX:
gen.writeString("T");
break;
default:
gen.writeNull();
break;
}
}
示例3: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(Enum value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
if (value == null) {
gen.writeNull();
return;
}
try {
PropertyDescriptor pd = getPropertyDescriptor(value, prop);
if (pd == null || pd.getReadMethod() == null) {
gen.writeString(value.name());
return;
}
Method m = pd.getReadMethod();
m.setAccessible(true);
gen.writeObject(m.invoke(value));
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
throw new RuntimeException(e);
}
}
示例4: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(ExternalModel object, JsonGenerator jsonGenerator, boolean writeStartAndEnd) throws IOException {
if (writeStartAndEnd) {
jsonGenerator.writeStartObject();
}
if (object.string != null) {
jsonGenerator.writeStringField("string", object.string);
} else {
jsonGenerator.writeFieldName("string");
jsonGenerator.writeNull();
}
if (writeStartAndEnd) {
jsonGenerator.writeEndObject();
}
}
示例5: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
/**
* Serialize a list of objects to a JsonGenerator.
*
* @param list The list of objects to serialize.
* @param jsonGenerator The JsonGenerator to which the list should be serialized
*/
public void serialize(List<T> list, JsonGenerator jsonGenerator) throws IOException {
jsonGenerator.writeStartArray();
for (T object : list) {
if (object != null) {
serialize(object, jsonGenerator, true);
} else {
jsonGenerator.writeNull();
}
}
jsonGenerator.writeEndArray();
}
示例6: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(Object value, JsonGenerator generator, boolean writeStartAndEnd) throws IOException {
if (value == null) {
generator.writeNull();
} else if (value instanceof String) {
generator.writeString((String)value);
} else if (value instanceof Integer) {
generator.writeNumber((Integer)value);
} else if (value instanceof Long) {
generator.writeNumber((Long)value);
} else if (value instanceof Float) {
generator.writeNumber((Float)value);
} else if (value instanceof Double) {
generator.writeNumber((Double)value);
} else if (value instanceof Boolean) {
generator.writeBoolean((Boolean)value);
} else if (value instanceof List) {
LoganSquare.mapperFor(List.class).serialize((List<Object>)value, generator, writeStartAndEnd);
} else if (value instanceof Map) {
LoganSquare.mapperFor(Map.class).serialize((Map<String, Object>)value, generator, writeStartAndEnd);
} else {
Class valueClass = value.getClass();
JsonMapper jsonMapper = LoganSquare.mapperFor(valueClass);
if (jsonMapper != null) {
if (writeStartAndEnd) {
generator.writeStartObject();
}
jsonMapper.serialize(value, generator, false);
if (writeStartAndEnd) {
generator.writeEndObject();
}
}
}
}
示例7: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(Date object, String fieldName, boolean writeFieldNameForObject, JsonGenerator jsonGenerator) throws IOException {
if (fieldName != null && object != null) {
jsonGenerator.writeStringField(fieldName, mDateFormat.get().format(object));
} else if (object != null) {
jsonGenerator.writeString(mDateFormat.get().format(object));
} else {
if (fieldName != null) {
jsonGenerator.writeFieldName(fieldName);
}
jsonGenerator.writeNull();
}
}
示例8: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(PropertyValue value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
if (value.getLocalizations().size() == 1 && value.getLocalizations().contains(Locale.ROOT)) {
// Simple property value
if (value.getValues().size() == 1) {
jgen.writeString(value.getValues().get(0));
} else {
jgen.writeStartArray();
for (String val : value.getValues()) {
jgen.writeString(val);
}
jgen.writeEndArray();
}
} else {
// Localized property value
Set<Locale> localizations = value.getLocalizations();
if (localizations.size() == 1) {
Locale lang = localizations.iterator().next();
writeSingleLocalization(jgen, lang, value.getValues(lang));
} else if (localizations.size() > 1) {
jgen.writeStartArray();
for (Locale language : localizations) {
writeSingleLocalization(jgen, language, value.getValues(language));
}
jgen.writeEndArray();
} else {
jgen.writeNull();
}
}
}
示例9: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(Nullable<Object> value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
if (value.isPresent()) {
Object object = value.get();
if (object == null) {
gen.writeNull();
} else {
gen.writeObject(object);
}
}
}
示例10: writeObject
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public boolean writeObject(Object obj, JsonGenerator jgen, boolean expand)
throws IOException {
if (obj == null) {
jgen.writeNull();
} else if ((obj instanceof TableDisplay) ||
(obj instanceof EvaluationResult) ||
(obj instanceof UpdatableEvaluationResult) ||
(obj instanceof BeakerCodeCell) ||
(obj instanceof ImageIcon) ||
(obj instanceof Date) ||
(obj instanceof BeakerDashboard) ||
(obj instanceof BufferedImage) ||
(obj instanceof TabbedOutputContainerLayoutManager) ||
(obj instanceof GridOutputContainerLayoutManager) ||
(obj instanceof CyclingOutputContainerLayoutManager) ||
(obj instanceof DashboardLayoutManager) ||
(obj instanceof OutputContainerCell) ||
(obj instanceof OutputContainer) ||
(obj instanceof BeakerProgressUpdate) ||
(obj instanceof EasyForm) ||
(obj instanceof Color)) {
logger.debug("basic object");
jgen.writeObject(obj);
} else
return runThreadSerializers(obj, jgen, expand) || runConfiguredSerializers(obj,
jgen,
expand);
return true;
}
示例11: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(RealmList<T> list, String fieldName, boolean writeFieldNameForObject, JsonGenerator jsonGenerator) throws IOException {
if (writeFieldNameForObject) {
if (list == null) {
return;
}
jsonGenerator.writeFieldName(fieldName);
}
if (list == null) {
jsonGenerator.writeNull();
return;
}
jsonGenerator.writeStartArray();
init();
for (T object : list) {
if (object != null) {
if (typeConverter != null) {
typeConverter.serialize(object, fieldName, false, jsonGenerator);
} else {
mapper.serialize(object, jsonGenerator, true);
}
} else {
jsonGenerator.writeNull();
}
}
jsonGenerator.writeEndArray();
}
示例12: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(AbstractEntity value, JsonGenerator jgen,
SerializerProvider provider) throws IOException,
JsonGenerationException {
if (value != null)
jgen.writeNumber(value.getId());
else
jgen.writeNull();
}
示例13: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(final DividendType value, final JsonGenerator gen, final SerializerProvider serializers) throws IOException {
if (value == null || value == DividendType.UNKNOWN) {
gen.writeNull();
return;
}
switch (value) {
case DIVIDEND_INCOME:
gen.writeString("Dividend income");
break;
case INTEREST_INCOME:
gen.writeString("Interest income");
break;
case STOCK_DIVIDEND:
gen.writeString("Stock dividend");
break;
case SHORT_TERM_CAPITAL_GAIN:
gen.writeString("Short term capital gain");
break;
case MEDIUM_TERM_CAPITAL_GAIN:
gen.writeString("Medium term capital gain");
break;
case LONG_TERM_CAPITAL_GAIN:
gen.writeString("Long term capital gain");
break;
case UNSPECIFIED_TERM_CAPITAL_GAIN:
gen.writeString("Unspecified term capital gain");
break;
default:
gen.writeNull();
break;
}
}
示例14: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(final SystemEventType value, final JsonGenerator gen, final SerializerProvider serializers) throws IOException {
if (value == null || value == SystemEventType.UNKNOWN) {
gen.writeNull();
return;
}
switch (value) {
case MESSAGES_START:
gen.writeString("O");
return;
case SYSTEM_HOURS_START:
gen.writeString("S");
return;
case REGULAR_MARKET_HOURS_START:
gen.writeString("R");
return;
case REGULAR_MARKET_HOURS_END:
gen.writeString("M");
return;
case SYSTEM_HOURS_END:
gen.writeString("E");
return;
case MESSAGES_END:
gen.writeString("C");
return;
default:
gen.writeNull();
}
}
示例15: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(Short s, JsonGenerator jGen,
SerializerProvider serializer) throws IOException,
JsonProcessingException {
if (s == null) jGen.writeNull();
else jGen.writeNumber(s.shortValue() & 0xffff);
}