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


Java JsonReader.endArray方法代码示例

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


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

示例1: fromJson

import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@FromJson
List<Applet> fromJson(JsonReader jsonReader, JsonAdapter<Applet> delegate) throws IOException {
    List<Applet> applets = new ArrayList<>();
    jsonReader.beginObject();
    while (jsonReader.hasNext()) {
        int index = jsonReader.selectName(OPTIONS);
        switch (index) {
            case -1:
                jsonReader.skipValue();
                break;
            case 0:
                jsonReader.beginArray();
                while (jsonReader.hasNext()) {
                    Applet applet = delegate.fromJson(jsonReader);
                    applets.add(applet);
                }
                jsonReader.endArray();
                break;
            default:
                throw new IllegalStateException("Unknown index: " + index);
        }
    }
    jsonReader.endObject();

    return applets;
}
 
开发者ID:IFTTT,项目名称:IFTTTSDK-Android,代码行数:27,代码来源:AppletListJsonAdapter.java

示例2: fromJson

import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@Nullable
@Override
public RealmList<T> fromJson(@NonNull JsonReader reader) throws IOException {
    RealmList<T> result = new RealmList<>();
    reader.beginArray();
    while (reader.hasNext()) {
        result.add(elementAdapter.fromJson(reader));
    }
    reader.endArray();
    return result;
}
 
开发者ID:Commit451,项目名称:Regalia,代码行数:12,代码来源:RealmListAdapter.java

示例3: visitNextOrSkip

import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
static void visitNextOrSkip(JsonReader reader, String name, Set<String> result)
    throws IOException {
  switch (reader.peek()) {
    case BEGIN_ARRAY:
      reader.beginArray();
      while (reader.hasNext()) visitObject(reader, name, result);
      reader.endArray();
      break;
    case BEGIN_OBJECT:
      visitObject(reader, name, result);
      break;
    default:
      reader.skipValue();
  }
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:16,代码来源:JsonReaders.java

示例4: fromJson

import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@Override
public HasMany<T> fromJson(JsonReader reader) throws IOException {
    HasMany<T> relationship = new HasMany<>();
    reader.beginObject();
    while (reader.hasNext()) {
        switch (reader.nextName()) {
            case "data":
                reader.beginArray();
                while (reader.hasNext()) {
                    relationship.add(resourceIdentifierJsonAdapter.fromJson(reader));
                }
                reader.endArray();
                break;
            case "meta":
                relationship.setMeta(nextNullableObject(reader, jsonBufferJsonAdapter));
                break;
            case "links":
                relationship.setLinks(nextNullableObject(reader, jsonBufferJsonAdapter));
                break;
            default:
                reader.skipValue();
                break;
        }
    }
    reader.endObject();
    return relationship;
}
 
开发者ID:kamikat,项目名称:moshi-jsonapi,代码行数:28,代码来源:HasMany.java

示例5: fromJson

import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@Override
public Set<T> fromJson(final JsonReader reader) throws IOException {
    final EnumSet<T> result = EnumSet.noneOf(enumType);
    final JsonReader.Token nextToken = reader.peek();
    final List<String> parts;

    if (nextToken == JsonReader.Token.BEGIN_ARRAY) {
        parts = new ArrayList<>();

        reader.beginArray();
        while (reader.hasNext()) {
            parts.add(reader.nextString());
        }
        reader.endArray();
    } else if (nextToken == JsonReader.Token.NULL) {
        reader.nextNull();

        parts = Collections.emptyList();
    } else {
        parts = Arrays.asList(reader.nextString().split(delimiter));
    }

    for (final String part : parts) {
        for (final Field field : enumType.getFields()) {
            Json annotation = field.getAnnotation(Json.class);

            if (annotation != null && annotation.name().equalsIgnoreCase(part)) {
                result.add(Enum.valueOf(enumType, field.getName()));

                break;
            }
        }
    }

    return result;
}
 
开发者ID:proxer,项目名称:ProxerLibJava,代码行数:37,代码来源:DelimitedEnumSetAdapterFactory.java

示例6: fromJson

import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@Override public SortedSet<T> fromJson(JsonReader reader) throws IOException {
  TreeSet<T> result = new TreeSet<>();
  reader.beginArray();
  while (reader.hasNext()) {
    result.add(elementAdapter.fromJson(reader));
  }
  reader.endArray();
  return result;
}
 
开发者ID:square,项目名称:moshi,代码行数:10,代码来源:CustomAdapterFactory.java

示例7: fromJson

import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@Override
public Span fromJson(JsonReader reader) throws IOException {
  Span.Builder result = Span.builder();
  reader.beginObject();
  while (reader.hasNext()) {
    String nextName = reader.nextName();
    if (reader.peek() == JsonReader.Token.NULL) {
      reader.skipValue();
      continue;
    }
    switch (nextName) {
      case "traceId":
        String traceId = reader.nextString();
        if (traceId.length() == 32) {
          result.traceIdHigh(lowerHexToUnsignedLong(traceId, 0));
        }
        result.traceId(lowerHexToUnsignedLong(traceId));
        break;
      case "name":
        result.name(reader.nextString());
        break;
      case "id":
        result.id(Util.lowerHexToUnsignedLong(reader.nextString()));
        break;
      case "parentId":
        result.parentId(Util.lowerHexToUnsignedLong(reader.nextString()));
        break;
      case "timestamp":
        result.timestamp(reader.nextLong());
        break;
      case "duration":
        result.duration(reader.nextLong());
        break;
      case "annotations":
        reader.beginArray();
        while (reader.hasNext()) {
          result.addAnnotation(ANNOTATION_ADAPTER.fromJson(reader));
        }
        reader.endArray();
        break;
      case "binaryAnnotations":
        reader.beginArray();
        while (reader.hasNext()) {
          result.addBinaryAnnotation(BINARY_ANNOTATION_ADAPTER.fromJson(reader));
        }
        reader.endArray();
        break;
      case "debug":
        result.debug(reader.nextBoolean());
        break;
      default:
        reader.skipValue();
    }
  }
  reader.endObject();
  return result.build();
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:58,代码来源:ZipkinAdapters.java

示例8: dump

import com.squareup.moshi.JsonReader; //导入方法依赖的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);
    }
}
 
开发者ID:kamikat,项目名称:moshi-jsonapi,代码行数:54,代码来源:MoshiHelper.java


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