當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonWriter.nullValue方法代碼示例

本文整理匯總了Java中com.google.gson.stream.JsonWriter.nullValue方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonWriter.nullValue方法的具體用法?Java JsonWriter.nullValue怎麽用?Java JsonWriter.nullValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.gson.stream.JsonWriter的用法示例。


在下文中一共展示了JsonWriter.nullValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: floatAdapter

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
private TypeAdapter<Number> floatAdapter(boolean serializeSpecialFloatingPointValues) {
    if (serializeSpecialFloatingPointValues) {
        return TypeAdapters.FLOAT;
    }
    return new TypeAdapter<Number>() {
        public Float read(JsonReader in) throws IOException {
            if (in.peek() != JsonToken.NULL) {
                return Float.valueOf((float) in.nextDouble());
            }
            in.nextNull();
            return null;
        }

        public void write(JsonWriter out, Number value) throws IOException {
            if (value == null) {
                out.nullValue();
                return;
            }
            Gson.this.checkValidFloatingPoint((double) value.floatValue());
            out.value(value);
        }
    };
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:24,代碼來源:Gson.java

示例2: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
public void write(JsonWriter out, Calendar value) throws IOException {
    if (value == null) {
        out.nullValue();
        return;
    }
    out.beginObject();
    out.name(YEAR);
    out.value((long) value.get(1));
    out.name(MONTH);
    out.value((long) value.get(2));
    out.name(DAY_OF_MONTH);
    out.value((long) value.get(5));
    out.name(HOUR_OF_DAY);
    out.value((long) value.get(11));
    out.name(MINUTE);
    out.value((long) value.get(12));
    out.name(SECOND);
    out.value((long) value.get(13));
    out.endObject();
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:21,代碼來源:TypeAdapters.java

示例3: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
public void write(JsonWriter out, T value) throws IOException {
    if (value == null) {
        out.nullValue();
        return;
    }
    out.beginObject();
    try {
        for (BoundField boundField : this.boundFields.values()) {
            if (boundField.serialized) {
                out.name(boundField.name);
                boundField.write(out, value);
            }
        }
        out.endObject();
    } catch (IllegalAccessException e) {
        throw new AssertionError();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:19,代碼來源:ReflectiveTypeAdapterFactory.java

示例4: floatAdapter

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
private TypeAdapter<Number> floatAdapter(boolean serializeSpecialFloatingPointValues) {
  if (serializeSpecialFloatingPointValues) {
    return TypeAdapters.FLOAT;
  }
  return new TypeAdapter<Number>() {
    @Override public Float read(JsonReader in) throws IOException {
      if (in.peek() == JsonToken.NULL) {
        in.nextNull();
        return null;
      }
      return (float) in.nextDouble();
    }
    @Override public void write(JsonWriter out, Number value) throws IOException {
      if (value == null) {
        out.nullValue();
        return;
      }
      float floatValue = value.floatValue();
      checkValidFloatingPoint(floatValue);
      out.value(value);
    }
  };
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:Gson.java

示例5: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
public void write(JsonWriter out, Collection<E> collection) throws IOException {
  if (collection == null) {
    out.nullValue();
    return;
  }

  out.beginArray();
  for (E element : collection) {
    elementTypeAdapter.write(out, element);
  }
  out.endArray();
}
 
開發者ID:odoo-mobile-intern,項目名稱:odoo-work,代碼行數:13,代碼來源:CollectionTypeAdapterFactory.java

示例6: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override
public void write(JsonWriter writer, File value) throws IOException {
    if (value == null) {
        writer.nullValue();
        return;
    }
    writer.value(value.getAbsolutePath());
}
 
開發者ID:VISNode,項目名稱:VISNode,代碼行數:9,代碼來源:FileAdapter.java

示例7: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
public void write(JsonWriter out, Object array) throws IOException {
    if (array == null) {
        out.nullValue();
        return;
    }
    out.beginArray();
    int length = Array.getLength(array);
    for (int i = 0; i < length; i++) {
        this.componentTypeAdapter.write(out, Array.get(array, i));
    }
    out.endArray();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:13,代碼來源:ArrayTypeAdapter.java

示例8: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override
public void write(JsonWriter out, LocalDate date) throws IOException {
    if (date == null) {
        out.nullValue();
    } else {
        out.value(formatter.print(date));
    }
}
 
開發者ID:ina-foss,項目名稱:afp-api-client,代碼行數:9,代碼來源:JSON.java

示例9: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override
public void write(JsonWriter out, DateTime date) throws IOException {
    if (date == null) {
        out.nullValue();
    } else {
        out.value(formatter.print(date));
    }
}
 
開發者ID:osimloeff,項目名稱:PI-Web-API-Client-Java-Android,代碼行數:9,代碼來源:JSON.java

示例10: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override
public void write(JsonWriter out, DateTime date) throws IOException {
    if (date == null) {
        out.nullValue();
    } else {
        out.value(printFormatter.print(date));
    }
}
 
開發者ID:hermannpencole,項目名稱:nifi-swagger-client,代碼行數:9,代碼來源:JSON.java

示例11: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override
public void write(JsonWriter out, String value) throws IOException {
    if (value == null) {
        out.nullValue();
        return;
    }
    out.value(value);
}
 
開發者ID:rascarlo,項目名稱:AURdroid,代碼行數:9,代碼來源:AurRpcService.java

示例12: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
public synchronized void write(JsonWriter out, Date value) throws IOException {
    if (value == null) {
        out.nullValue();
    } else {
        out.value(this.enUsFormat.format(value));
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:8,代碼來源:DateTypeAdapter.java

示例13: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override
public void write(JsonWriter jsonWriter, SparseArray<T> tSparseArray) throws IOException {
    if (tSparseArray == null) {
        jsonWriter.nullValue();
        return;
    }
    gson.toJson(gson.toJsonTree(tSparseArray, typeOfSparseArrayOfT), jsonWriter);
}
 
開發者ID:MessageOnTap,項目名稱:MessageOnTap_API,代碼行數:9,代碼來源:SparseArrayTypeAdapter.java

示例14: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
public void write(JsonWriter out, JsonElement value) throws IOException {
    if (value == null || value.isJsonNull()) {
        out.nullValue();
    } else if (value.isJsonPrimitive()) {
        JsonPrimitive primitive = value.getAsJsonPrimitive();
        if (primitive.isNumber()) {
            out.value(primitive.getAsNumber());
        } else if (primitive.isBoolean()) {
            out.value(primitive.getAsBoolean());
        } else {
            out.value(primitive.getAsString());
        }
    } else if (value.isJsonArray()) {
        out.beginArray();
        Iterator it = value.getAsJsonArray().iterator();
        while (it.hasNext()) {
            write(out, (JsonElement) it.next());
        }
        out.endArray();
    } else if (value.isJsonObject()) {
        out.beginObject();
        for (Entry<String, JsonElement> e : value.getAsJsonObject().entrySet()) {
            out.name((String) e.getKey());
            write(out, (JsonElement) e.getValue());
        }
        out.endObject();
    } else {
        throw new IllegalArgumentException("Couldn't write " + value.getClass());
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:31,代碼來源:TypeAdapters.java

示例15: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override
public void write(JsonWriter out, Class value) throws IOException {
  if (value == null) {
    out.nullValue();
  } else {
    throw new UnsupportedOperationException("Attempted to serialize java.lang.Class: "
        + value.getName() + ". Forgot to register a type adapter?");
  }
}
 
開發者ID:odoo-mobile-intern,項目名稱:odoo-work,代碼行數:10,代碼來源:TypeAdapters.java


注:本文中的com.google.gson.stream.JsonWriter.nullValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。