本文整理汇总了Java中com.google.gson.stream.JsonWriter.beginArray方法的典型用法代码示例。如果您正苦于以下问题:Java JsonWriter.beginArray方法的具体用法?Java JsonWriter.beginArray怎么用?Java JsonWriter.beginArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gson.stream.JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.beginArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serialize
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void serialize(JsonWriter writer) throws IOException {
writer.beginObject();
writer.name("messages");
writer.beginArray();
for(MessageEntry entry : messages) {
writer.beginObject();
writer.name(entry.toString());
entry.serialize(writer);
writer.endObject();
}
writer.endArray();
writer.endObject();
}
示例2: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter writer, Car3 car) throws IOException {
writer.beginObject();
writer.name("mark").value(car.getMark());
writer.name("model").value(car.getModel());
writer.name("type").value(car.getType());
writer.name("maker").value(car.getMaker());
double costIncludingVAT = car.getCost() + 0.21 * car.getCost();// Add 21% VAT
writer.name("cost").value(costIncludingVAT);
writer.name("colors");
writer.beginArray();
for (String color : car.getColors()) {
writer.value(color);
}
writer.endArray();
writer.endObject();
}
示例3: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter out, GsonProperty property, Object value) throws IOException {
final Class<?> simpleType = property.getType();
out.beginArray();
int length = Array.getLength(value);
if(length > 0) {
if (simpleType.isPrimitive() || isBoxedClass(simpleType)) {
for (int i = 0; i < length; i++) {
writePrimitiveOrItsBox(out, simpleType, Array.get(value, i));
}
} else {
TypeAdapter adapter = getTypeAdapter(simpleType);
for (int i = 0; i < length; i++) {
adapter.write(out, Array.get(value, i));
}
}
}
out.endArray();
}
示例4: saveToWriter
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
public static void saveToWriter(Collection<? extends Record> records, Writer writer) throws IOException {
JsonWriter jsonWriter = new JsonWriter(writer);
jsonWriter.beginArray();
for (Record record : records) {
jsonWriter.beginObject();
jsonWriter.name(ALGORITHM_ID).value(record.getAlgorithmId());
jsonWriter.name(DATASET_ID).value(record.getDatasetId());
jsonWriter.name(MEASUREMENT_METHOD).value(record.getMeasurementMethod());
jsonWriter.name(MEASUREMENT_AUTHOR).value(record.getMeasurementAuthor());
jsonWriter.name(MEASUREMENT_TIME).value(record.getMeasurementTime().toString());
jsonWriter.name(CPU_MODEL_NAME).value(record.getCpuModelName());
jsonWriter.name(JAVA_RUNTIME_VERSION).value(record.getJavaRuntimeVersion());
jsonWriter.name(MEASUREMENTS).beginArray();
for (double measurement : record.getMeasurements()) {
jsonWriter.value(measurement);
}
jsonWriter.endArray();
jsonWriter.name(COMMENT).value(record.getComment());
jsonWriter.endObject();
}
jsonWriter.endArray();
}
示例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) {
this.elementTypeAdapter.write(out, element);
}
out.endArray();
}
示例6: serialize
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void serialize(JsonWriter writer) throws IOException {
writer.beginArray();
for(Bound bound : bounds) {
writer.beginArray();
writer.value(bound.getMin());
writer.value(bound.getMax());
writer.endArray();
}
writer.endArray();
}
示例7: serialize
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void serialize(JsonWriter writer) throws IOException {
writer.beginObject();
writer.name("enabled");
writer.value(enabled);
writer.name("keyword");
writer.value(keyword);
writer.name("type");
writer.value(type.name());
writer.name("trigger");
writer.value(trigger.name());
writer.name("delay");
writer.value(getDelay());
writer.name("messages");
writer.beginArray();
for(String msg : messages) {
writer.value(msg);
}
writer.endArray();
writer.endObject();
}
示例8: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter out, SemanticVersion version) throws IOException {
out.beginArray();
out.value(version.major());
out.value(version.minor());
if(version.patch() != 0) out.value(version.patch());
out.endArray();
}
示例9: writeNonNull
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
protected void writeNonNull(JsonWriter out, Set<T> value) throws IOException {
out.beginArray();
for(T t : value) {
out.value(t.name());
}
out.endArray();
}
示例10: 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();
}
示例11: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter out, List<Car3> value) throws IOException {
out.beginArray();
for(Car3 car3 : value){
mAdapter.write(out, car3);
}
out.endArray();
}
示例12: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter out, List<String> value) throws IOException {
out.beginArray();
for(String str : value){
out.value(str);
}
out.endArray();
}
示例13: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
public void write(JsonWriter out, BitSet src) throws IOException {
if (src == null) {
out.nullValue();
return;
}
out.beginArray();
for (int i = 0; i < src.length(); i++) {
int value = (src.get(i)) ? 1 : 0;
out.value(value);
}
out.endArray();
}
示例14: 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();
}
示例15: writeJson
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
public void writeJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.beginObject();
jsonWriter.name("oid").value(oid);
jsonWriter.name("indices");
jsonWriter.beginArray();
for (int i : indices) {
jsonWriter.beginObject();
jsonWriter.name("i").value(i);
jsonWriter.endObject();
}
jsonWriter.endArray();
jsonWriter.name("vertices");
jsonWriter.beginArray();
for (float v : vertices) {
jsonWriter.beginObject();
jsonWriter.name("v").value(v);
jsonWriter.endObject();
}
jsonWriter.endArray();
jsonWriter.name("normals");
jsonWriter.beginArray();
for (float n : normals) {
jsonWriter.beginObject();
jsonWriter.name("n").value(n);
jsonWriter.endObject();
}
jsonWriter.endArray();
jsonWriter.name("bound");
bound.writeJson(jsonWriter);
jsonWriter.name("typeName").value(typeName);
jsonWriter.name("defaultVisiable").value(defaultVisiable);
if (color != null) {
jsonWriter.name("color");
color.writeJson(jsonWriter);
}
jsonWriter.endObject();
}