本文整理汇总了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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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();
}
示例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();
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}
示例13: fromJson
import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@Override public ByteString fromJson(JsonReader reader) throws IOException {
String base64 = reader.nextString();
return ByteString.decodeBase64(base64);
}