當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。