当前位置: 首页>>代码示例>>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;未经允许,请勿转载。