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


Java JsonReader.nextString方法代码示例

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


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

示例1: compute

import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@Override protected List<String> compute() {
  try (Response response = client.newCall(describeElasticsearchDomain).execute()) {
    if (!response.isSuccessful()) {
      throw new IllegalStateException(response.body().string());
    }

    JsonReader endpointReader =
        enterPath(JsonReader.of(response.body().source()), "DomainStatus", "Endpoint");
    checkArgument(endpointReader != null, "DomainStatus.Endpoint wasn't present in response");

    String endpoint = endpointReader.nextString();
    if (!endpoint.startsWith("https://")) {
      endpoint = "https://" + endpoint;
    }
    log.fine("using endpoint " + endpoint);
    return Collections.singletonList(endpoint);
  } catch (IOException e) {
    throw new IllegalStateException("couldn't lookup domain endpoint", e);
  }
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:21,代码来源:ElasticsearchDomainEndpoint.java

示例2: read

import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@FromJson
public AnInterface read(JsonReader jsonReader) throws IOException {
    jsonReader.beginObject();

    String name = null;
    while (jsonReader.hasNext()) {
        switch (jsonReader.nextName()) {
            case "name":
                name = jsonReader.nextString();
                break;
        }
    }

    jsonReader.endObject();
    return new AnImplementation(name);
}
 
开发者ID:apptik,项目名称:jus,代码行数:17,代码来源:MoshiConverterFactoryTest.java

示例3: read

import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@FromJson public AnInterface read(JsonReader jsonReader) throws IOException {
  jsonReader.beginObject();

  String name = null;
  while (jsonReader.hasNext()) {
    switch (jsonReader.nextName()) {
      case "name":
        name = jsonReader.nextString();
        break;
    }
  }

  jsonReader.endObject();
  return new AnImplementation(name);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:MoshiConverterFactoryTest.java

示例4: readQualified

import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@FromJson @Qualifier public String readQualified(JsonReader reader) throws IOException {
  String string = reader.nextString();
  if (string.equals("qualified!")) {
    return "it worked!";
  }
  throw new AssertionError("Found: " + string);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:MoshiConverterFactoryTest.java

示例5: intercept

import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@Override public Response intercept(Chain chain) throws IOException {
  Request input = chain.request();
  Request signed = sign(input);
  Response response = chain.proceed(signed);
  if (response.code() == 403) {
    try (ResponseBody body = response.body()) {
      JsonReader message = enterPath(JsonReader.of(body.source()), "message");
      if (message != null) throw new IllegalStateException(message.nextString());
    }
    throw new IllegalStateException(response.toString());
  }
  return response;
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:14,代码来源:AWSSignatureVersion4.java

示例6: fromJson

import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@Override
public Endpoint fromJson(JsonReader reader) throws IOException {
  Endpoint.Builder result = Endpoint.builder();
  reader.beginObject();
  while (reader.hasNext()) {
    switch (reader.nextName()) {
      case "serviceName":
        result.serviceName(reader.nextString());
        break;
      case "ipv4":
        String[] ipv4String = reader.nextString().split("\\.", 5);
        int ipv4 = 0;
        for (String b : ipv4String) {
          ipv4 = ipv4 << 8 | (Integer.parseInt(b) & 0xff);
        }
        result.ipv4(ipv4);
        break;
      case "ipv6":
        String input = reader.nextString();
        // Shouldn't hit DNS, because it's an IP string literal.
        byte[] ipv6 = InetAddress.getByName(input).getAddress();
        result.ipv6(ipv6);
        break;
      case "port":
        result.port(reader.nextInt());
        break;
      default:
        reader.skipValue();
    }
  }
  reader.endObject();
  return result.build();
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:34,代码来源:ZipkinAdapters.java

示例7: nextNullableString

import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
public static String nextNullableString(JsonReader reader) throws IOException {
    if (reader.peek() == JsonReader.Token.NULL) {
        reader.skipValue();
        return null;
    } else {
        return reader.nextString();
    }
}
 
开发者ID:kamikat,项目名称:moshi-jsonapi,代码行数:9,代码来源:MoshiHelper.java

示例8: getServiceException

import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
private ServiceException getServiceException(JsonReader reader)
{
    ServiceException serviceException = new ServiceException();
    try
    {
        reader.beginObject();
        while(reader.hasNext())
        {
            String exception = reader.nextName();
            if(exception.equals("serviceException") || exception.equals("policyException"))
            {
                reader.beginObject();
                while(reader.hasNext())
                {
                    String name = reader.nextName();
                    if(name.equals("messageId"))
                    {
                        String messageId = reader.nextString();
                        serviceException.setMessageId(messageId);
                    }
                    else if(name.equals("text"))
                    {
                        String text = reader.nextString();
                        serviceException.setText(text);
                    }
                    else if(name.equals("variables"))
                    {
                        readVariableArray(reader, serviceException);
                    }
                }
            }
        }
    }
    catch(IOException e)
    {
        e.printStackTrace();
    }
    return serviceException;
}
 
开发者ID:DevAlves1993,项目名称:OSmsJava,代码行数:40,代码来源:OSms.java

示例9: readVariableArray

import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
private void readVariableArray(JsonReader reader, ServiceException serviceException) throws IOException
{
    reader.beginArray();
    while(reader.hasNext())
    {
        String variable = reader.nextString();
        serviceException.addVariable(variable);
    }
}
 
开发者ID:DevAlves1993,项目名称:OSmsJava,代码行数:10,代码来源:OSms.java

示例10: fromJson

import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@FromJson
@Nullable
Stage fromJson(JsonReader jsonReader, JsonAdapter<Stage> delegate) throws IOException {
  String value = jsonReader.nextString();

  Stage stage;
  if (value.startsWith("in-progress")) {
    stage = Stage.IN_PROGRESS;
  } else {
    stage = delegate.fromJsonValue(value);
  }
  return stage;
}
 
开发者ID:square,项目名称:moshi,代码行数:14,代码来源:CustomAdapterWithDelegate.java

示例11: fromJson

import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@Override public T fromJson(JsonReader reader) throws IOException {
  String name = reader.nextString();
  T constant = nameConstantMap.get(name);
  if (constant != null) return constant;
  return fallbackConstant;
}
 
开发者ID:serj-lotutovici,项目名称:moshi-lazy-adapters,代码行数:7,代码来源:FallbackEnumJsonAdapter.java

示例12: fromJson

import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@FromJson GitHubEvent fromJson(JsonReader json) throws IOException {
    GitHubPayload payload = null;
    GitHubEventType type = null;
    User actor = null;
    User org = null;
    String id = null;
    Date createdAt = null;
    boolean _public = false;
    Repository repo = null;

    Moshi moshi = ServiceGenerator.moshi;

    json.beginObject();
    while (json.hasNext()) {
        switch (json.nextName()) {
            case "type":
                type = GitHubEventType.valueOf(json.nextString());
                break;
            case "actor":
                actor = User.jsonAdapter(moshi).fromJson(json);
                break;
            case "org":
                org = User.jsonAdapter(moshi).fromJson(json);
                break;
            case "id":
                id = json.nextString();
                break;
            case "created_at":
                createdAt = new FormattedTimeAdapter().fromJson(json.nextString());
                break;
            case "public":
                _public = json.nextBoolean();
                break;
            case "repo":
                repo = Repository.jsonAdapter(moshi).fromJson(json);
                break;
            case "payload":
                payload = readPayload(type, moshi, json).toBuilder().type(type).build();
                break;
            default:
                json.skipValue();
                break;
        }
    }
    json.endObject();

    return GitHubEvent.builder()
            .type(type)
            .id(id)
            .payload(payload)
            .repo(repo)
            .actor(actor)
            .org(org)
            .isPublic(_public)
            .createdAt(createdAt)
            .build();
}
 
开发者ID:Meisolsson,项目名称:GitHubSdk,代码行数:58,代码来源:GitHubEventAdapter.java

示例13: fromJson

import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@Override public ByteString fromJson(JsonReader reader) throws IOException {
  String base64 = reader.nextString();
  return ByteString.decodeBase64(base64);
}
 
开发者ID:square,项目名称:moshi,代码行数:5,代码来源:ByteStrings.java


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