当前位置: 首页>>代码示例>>Java>>正文


Java JsonGenerator.writeNull方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:WojciechZankowski,项目名称:iextrading4j,代码行数:23,代码来源:DividendQualificationSerializer.java

示例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;
    }
}
 
开发者ID:WojciechZankowski,项目名称:iextrading4j,代码行数:26,代码来源:TradingStatusTypeSerializer.java

示例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);
    }
}
 
开发者ID:thlcly,项目名称:Dude,代码行数:20,代码来源:CustomEnumSerializer.java

示例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();
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:ExternalModel$$JsonObjectMapper.java

示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:JsonMapper.java

示例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();
            }
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:38,代码来源:ObjectMapper.java

示例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();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:DateTypeConverter.java

示例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();
    }
  }
}
 
开发者ID:dbmdz,项目名称:iiif-apis,代码行数:31,代码来源:PropertyValueSerializer.java

示例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);
		}
	}
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:12,代码来源:NullableSerializer.java

示例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;
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:32,代码来源:BasicObjectSerializer.java

示例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();
}
 
开发者ID:Commit451,项目名称:Regalia,代码行数:29,代码来源:RealmListLoganSquareConverter.java

示例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();
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:10,代码来源:ManyToOneSerializer.java

示例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;
    }
}
 
开发者ID:WojciechZankowski,项目名称:iextrading4j,代码行数:35,代码来源:DividendTypeSerializer.java

示例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();
    }
}
 
开发者ID:WojciechZankowski,项目名称:iextrading4j,代码行数:31,代码来源:SystemEventTypeSerializer.java

示例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);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:8,代码来源:UShortSerializer.java


注:本文中的com.fasterxml.jackson.core.JsonGenerator.writeNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。