当前位置: 首页>>代码示例>>Java>>正文


Java JsonWriter.endObject方法代码示例

本文整理汇总了Java中com.squareup.moshi.JsonWriter.endObject方法的典型用法代码示例。如果您正苦于以下问题:Java JsonWriter.endObject方法的具体用法?Java JsonWriter.endObject怎么用?Java JsonWriter.endObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.squareup.moshi.JsonWriter的用法示例。


在下文中一共展示了JsonWriter.endObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writePackageFile

import com.squareup.moshi.JsonWriter; //导入方法依赖的package包/类
/**
 * Generates a dummy package.json file to silence npm warnings
 */
private void writePackageFile(File apolloPackageFile) {
  try {
    JsonWriter writer = JsonWriter.of(Okio.buffer(Okio.sink(apolloPackageFile)));

    writer.beginObject();

    writer.name("name").value("apollo-android");
    writer.name("version").value("0.0.1");
    writer.name("description").value("Generates Java code based on a GraphQL schema and query documents. Uses " +
        "apollo-codegen under the hood.");
    writer.name("name").value("apollo-android");
    writer.name("repository");
    writer.beginObject();
    writer.name("type").value("git");
    writer.name("url").value("git+https://github.com/apollostack/apollo-android.git");
    writer.endObject();
    writer.name("author").value("Apollo");
    writer.name("license").value("MIT");
    writer.endObject();
    writer.close();
  }
  catch (IOException e) {
    e.printStackTrace();
  }
}
 
开发者ID:apollographql,项目名称:apollo-android,代码行数:29,代码来源:ApolloCodeGenInstallTask.java

示例2: toJson

import com.squareup.moshi.JsonWriter; //导入方法依赖的package包/类
/**
 * Recursively writes the respective roots forming a json object that resembles the {@code path}
 * wrapping the type of the {@code adapter}.
 */
private static <T> void toJson(JsonAdapter<T> adapter, JsonWriter writer, T value,
    String[] path, int index) throws IOException {
  if (value != null || writer.getSerializeNulls()) {
    if (index == path.length) {
      adapter.toJson(writer, value);
    } else {
      writer.beginObject();
      writer.name(path[index]);
      toJson(adapter, writer, value, path, ++index);
      writer.endObject();
    }
  } else {
    // If we don't propagate the null value the writer will throw.
    writer.nullValue();
  }
}
 
开发者ID:serj-lotutovici,项目名称:moshi-lazy-adapters,代码行数:21,代码来源:WrappedJsonAdapter.java

示例3: toJson

import com.squareup.moshi.JsonWriter; //导入方法依赖的package包/类
@Override
public void toJson(JsonWriter writer) throws IOException {
  writer.beginObject();
  writer.name("id").value(id);
  writer.name("description").value(description());
  writer.name("type").value(type);
  writer.endObject();
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:9,代码来源:SimulatedInventory.java

示例4: errorResponseFor

import com.squareup.moshi.JsonWriter; //导入方法依赖的package包/类
@NotNull
private Response errorResponseFor(final Throwable e) {
  Buffer buffer = new Buffer();
  JsonWriter writer = JsonWriter.of(buffer);
  try {
    writer.beginObject();
    writer.name("error").value(e.getMessage());
    writer.endObject();
  } catch (IOException ignored) {
  }
  return Response.newFixedLengthResponse(Status.INTERNAL_ERROR, JSON, buffer.readByteArray());
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:13,代码来源:TelemetryController.java

示例5: 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();
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:14,代码来源:Subscription.java

示例6: 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();
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:15,代码来源:Subscription.java

示例7: writeInventory

import com.squareup.moshi.JsonWriter; //导入方法依赖的package包/类
@Override
public void writeInventory(BufferedSink sink) throws IOException {
  JsonWriter writer = JsonWriter.of(sink);
  writer.setIndent("  ");
  writer.beginObject();
  writer.name("items");
  writeItems(writer);
  writer.name("measures");
  writeMeasures(writer);
  writer.endObject();
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:12,代码来源:AbstractInventory.java

示例8: 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();
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:12,代码来源:AbstractInventory.java

示例9: 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();
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:13,代码来源:AbstractInventory.java

示例10: toJson

import com.squareup.moshi.JsonWriter; //导入方法依赖的package包/类
@Override
public void toJson(JsonWriter out, Feed feed) throws IOException {
    out.beginObject();

    // Only write url for feeds that are not in the database
    if(!RealmObject.isManaged(feed)) {
        out.name("url");
        out.value(feed.getUrl());
    }

    out.name("folderId");
    out.value(feed.getFolderId());

    out.endObject();
}
 
开发者ID:schaal,项目名称:ocreader,代码行数:16,代码来源:FeedTypeAdapter.java

示例11: toJson

import com.squareup.moshi.JsonWriter; //导入方法依赖的package包/类
@Override
public void toJson(JsonWriter out, Item item) throws IOException {
    out.beginObject();

    out.name(Item.ID).value(item.getId());
    out.name(Item.CONTENT_HASH).value(item.getContentHash());

    if(item.isUnreadChanged())
        out.name("isUnread").value(item.isUnread());

    if(item.isStarredChanged())
        out.name("isStarred").value(item.isStarred());

    out.endObject();
}
 
开发者ID:schaal,项目名称:ocreader,代码行数:16,代码来源:ItemTypeAdapter.java

示例12: toJson

import com.squareup.moshi.JsonWriter; //导入方法依赖的package包/类
@Override
public void toJson(JsonWriter writer, ResourceIdentifier value) throws IOException {
    writer.beginObject();
    writer.name("type").value(value.getType());
    writer.name("id").value(value.getId());
    writeNullable(writer, jsonBufferJsonAdapter, "meta", value.getMeta());
    writer.endObject();
}
 
开发者ID:kamikat,项目名称:moshi-jsonapi,代码行数:9,代码来源:ResourceIdentifier.java

示例13: 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();
}
 
开发者ID:kamikat,项目名称:moshi-jsonapi,代码行数:14,代码来源:HasMany.java

示例14: toJson

import com.squareup.moshi.JsonWriter; //导入方法依赖的package包/类
@Override
public void toJson(JsonWriter writer, HasOne<T> value) throws IOException {
    writer.beginObject();
    writeNullable(writer, resourceIdentifierJsonAdapter, "data", value.linkedResource);
    writeNullable(writer, jsonBufferJsonAdapter, "meta", value.getMeta());
    writeNullable(writer, jsonBufferJsonAdapter, "links", value.getLinks());
    writer.endObject();
}
 
开发者ID:kamikat,项目名称:moshi-jsonapi,代码行数:9,代码来源:HasOne.java

示例15: toJson

import com.squareup.moshi.JsonWriter; //导入方法依赖的package包/类
@Override
public void toJson(JsonWriter writer, Error value) throws IOException {
    writer.beginObject();
    writer.name("id").value(value.getId());
    writer.name("status").value(value.getStatus());
    writer.name("code").value(value.getCode());
    writer.name("title").value(value.getTitle());
    writer.name("detail").value(value.getDetail());
    writeNullable(writer, jsonBufferJsonAdapter, "source", value.getSource());
    writeNullable(writer, jsonBufferJsonAdapter, "meta", value.getMeta());
    writeNullable(writer, jsonBufferJsonAdapter, "links", value.getLinks());
    writer.endObject();
}
 
开发者ID:kamikat,项目名称:moshi-jsonapi,代码行数:14,代码来源:Error.java


注:本文中的com.squareup.moshi.JsonWriter.endObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。