本文整理汇总了Java中com.squareup.moshi.JsonWriter.endArray方法的典型用法代码示例。如果您正苦于以下问题:Java JsonWriter.endArray方法的具体用法?Java JsonWriter.endArray怎么用?Java JsonWriter.endArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.squareup.moshi.JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.endArray方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toJson
import com.squareup.moshi.JsonWriter; //导入方法依赖的package包/类
@Override
public void toJson(@NonNull JsonWriter writer, RealmList<T> value) throws IOException {
writer.beginArray();
for (T element : value) {
elementAdapter.toJson(writer, element);
}
writer.endArray();
}
示例2: measurementsToJson
import com.squareup.moshi.JsonWriter; //导入方法依赖的package包/类
public void measurementsToJson(BufferedSink sink) throws IOException {
long ts = System.currentTimeMillis();
JsonWriter writer = JsonWriter.of(sink);
writer.beginObject();
writer.name("timestamp").value(ts);
writer.name("data");
writer.beginArray();
for (DoubleSupplier m : measurements) {
writer.value(m.getAsDouble());
}
writer.endArray();
writer.endObject();
}
示例3: toJson
import com.squareup.moshi.JsonWriter; //导入方法依赖的package包/类
public void toJson(BufferedSink sink) throws IOException {
long ts = System.currentTimeMillis();
JsonWriter writer = JsonWriter.of(sink);
writer.beginObject();
writer.name("type").value("subscription");
writer.name("timestamp").value(ts);
writer.name("descriptions");
writer.beginArray();
for (String d : descriptions) {
writer.value(d);
}
writer.endArray();
writer.endObject();
}
示例4: writeItems
import com.squareup.moshi.JsonWriter; //导入方法依赖的package包/类
void writeItems(JsonWriter writer) throws IOException {
writer.beginArray();
for (int i = 0; i < items.size(); i++) {
writer.beginObject();
writer.name("id").value(i);
writer.name("type").value(items.get(i).type());
writer.name("description").value(items.get(i).description());
writer.endObject();
}
writer.endArray();
}
示例5: writeMeasures
import com.squareup.moshi.JsonWriter; //导入方法依赖的package包/类
void writeMeasures(JsonWriter writer) throws IOException {
Map<String, Set<Measure>> measures = new HashMap<>();
items.forEach(it -> measures.putIfAbsent(it.type(), it.measures()));
writer.beginArray();
for (Entry<String, Set<Measure>> entry : measures.entrySet()) {
writeDeviceMeasures(writer, entry.getKey(), entry.getValue());
}
writer.endArray();
}
示例6: writeDeviceMeasures
import com.squareup.moshi.JsonWriter; //导入方法依赖的package包/类
void writeDeviceMeasures(JsonWriter writer, String type, Set<Measure> measures)
throws IOException {
writer.beginObject();
writer.name("deviceType").value(type);
writer.name("deviceMeasures");
writer.beginArray();
for (Measure m : measures) {
writeMeasure(writer, m);
}
writer.endArray();
writer.endObject();
}
示例7: toJson
import com.squareup.moshi.JsonWriter; //导入方法依赖的package包/类
@Override
public void toJson(BufferedSink sink) throws IOException {
JsonWriter writer = JsonWriter.of(sink);
writer.setIndent(" ");
writer.beginArray();
for (Item item : items) {
item.toJson(writer);
}
writer.endArray();
}
示例8: toJson
import com.squareup.moshi.JsonWriter; //导入方法依赖的package包/类
@Override
public void toJson(JsonWriter writer, HasMany<T> value) throws IOException {
writer.beginObject();
writer.name("data");
writer.beginArray();
for (ResourceIdentifier resource : value.linkedResources) {
resourceIdentifierJsonAdapter.toJson(writer, resource);
}
writer.endArray();
writeNullable(writer, jsonBufferJsonAdapter, "meta", value.getMeta());
writeNullable(writer, jsonBufferJsonAdapter, "links", value.getLinks());
writer.endObject();
}
示例9: toJson
import com.squareup.moshi.JsonWriter; //导入方法依赖的package包/类
@Override public void toJson(JsonWriter writer, SortedSet<T> set) throws IOException {
writer.beginArray();
for (T element : set) {
elementAdapter.toJson(writer, element);
}
writer.endArray();
}
示例10: dump
import com.squareup.moshi.JsonWriter; //导入方法依赖的package包/类
public static void dump(JsonReader reader, JsonWriter writer) throws IOException {
int nested = 0;
boolean nullFlag = writer.getSerializeNulls();
writer.setSerializeNulls(true);
try {
while (reader.peek() != JsonReader.Token.END_DOCUMENT) {
switch (reader.peek()) {
case BEGIN_ARRAY:
nested++;
reader.beginArray();
writer.beginArray();
break;
case END_ARRAY:
reader.endArray();
writer.endArray();
if (0 == --nested) return;
break;
case BEGIN_OBJECT:
nested++;
reader.beginObject();
writer.beginObject();
break;
case END_OBJECT:
reader.endObject();
writer.endObject();
if (0 == --nested) return;
break;
case NAME:
writer.name(reader.nextName());
break;
case NUMBER:
try {
writer.value(reader.nextLong());
} catch (Exception ignored) {
writer.value(reader.nextDouble());
}
break;
case BOOLEAN:
writer.value(reader.nextBoolean());
break;
case STRING:
writer.value(reader.nextString());
break;
case NULL:
reader.nextNull();
writer.nullValue();
break;
}
}
} finally {
writer.setSerializeNulls(nullFlag);
}
}