本文整理汇总了Java中com.squareup.moshi.JsonReader.nextName方法的典型用法代码示例。如果您正苦于以下问题:Java JsonReader.nextName方法的具体用法?Java JsonReader.nextName怎么用?Java JsonReader.nextName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.squareup.moshi.JsonReader
的用法示例。
在下文中一共展示了JsonReader.nextName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromJson
import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@Override
public Folder fromJson(JsonReader in) throws IOException {
if (in.peek() == JsonReader.Token.NULL) {
in.nextNull();
return null;
}
Folder folder = new Folder();
in.beginObject();
while (in.hasNext()) {
String name = in.nextName();
switch (name) {
case "id":
folder.setId(in.nextLong());
break;
case "name":
folder.setName(in.nextString());
break;
default:
Log.w(TAG, "Unknown value in folder json: " + name);
in.skipValue();
break;
}
}
in.endObject();
return folder;
}
示例2: readAvatar
import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
private void readAvatar(JsonReader in, User user, String name) throws IOException {
in.beginObject();
while(in.hasNext()) {
String avatarName = in.nextName();
switch (avatarName) {
case "data":
user.setAvatar(in.nextString());
break;
case "mime":
user.setAvatarMime(in.nextString());
break;
default:
Log.w(TAG, "Unknown value in avatar json: " + name);
in.skipValue();
break;
}
}
in.endObject();
}
示例3: readWarnings
import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
private void readWarnings(JsonReader in, Status status) throws IOException {
in.beginObject();
while(in.hasNext()) {
String name = in.nextName();
switch (name) {
case "improperlyConfiguredCron":
status.setImproperlyConfiguredCron(in.nextBoolean());
break;
case "incorrectDbCharset":
// TODO: 11/9/17 Show warning
in.skipValue();
break;
default:
Log.w(TAG, "Unknown value in status warnings json: " + name);
in.skipValue();
}
}
in.endObject();
}
示例4: fromJson
import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@Override
public Annotation fromJson(JsonReader reader) throws IOException {
Annotation.Builder result = Annotation.builder();
reader.beginObject();
while (reader.hasNext()) {
switch (reader.nextName()) {
case "timestamp":
result.timestamp(reader.nextLong());
break;
case "value":
result.value(reader.nextString());
break;
case "endpoint":
result.endpoint(ENDPOINT_ADAPTER.fromJson(reader));
break;
default:
reader.skipValue();
}
}
reader.endObject();
return result.build();
}
示例5: fromJson
import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@Override
public ResourceIdentifier fromJson(JsonReader reader) throws IOException {
ResourceIdentifier object = new ResourceIdentifier();
reader.beginObject();
while (reader.hasNext()) {
switch (reader.nextName()) {
case "id":
object.setId(nextNullableString(reader));
break;
case "type":
object.setType(nextNullableString(reader));
break;
case "meta":
object.setMeta(nextNullableObject(reader, jsonBufferJsonAdapter));
break;
default:
reader.skipValue();
break;
}
}
reader.endObject();
return object;
}
示例6: fromJson
import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@Override
public HasOne<T> fromJson(JsonReader reader) throws IOException {
HasOne<T> relationship = new HasOne<>();
reader.beginObject();
while (reader.hasNext()) {
switch (reader.nextName()) {
case "data":
relationship.set(nextNullableObject(reader, resourceIdentifierJsonAdapter));
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;
}
示例7: jsonToServiceError
import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
private ServiceError jsonToServiceError(Response response)
{
ServiceError serviceError = null;
BufferedSource source = response.body()
.source();
JsonReader reader = JsonReader.of(source);
try
{
reader.beginObject();
while(reader.hasNext())
{
String name = reader.nextName();
if(name.equals("requestError"))
{
ServiceException serviceException = getServiceException(reader);
serviceError = initServiceError(serviceError, serviceException);
}
}
}
catch(IOException e)
{
e.printStackTrace();
}
return serviceError;
}
示例8: 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);
}
示例9: 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);
}
示例10: fromJson
import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@Override
public User fromJson(JsonReader in) throws IOException {
if (in.peek() == JsonReader.Token.NULL) {
in.nextNull();
return null;
}
User user = new User();
in.beginObject();
while (in.hasNext()) {
String name = in.nextName();
switch (name) {
case "userId":
user.setUserId(in.nextString());
break;
case "displayName":
user.setDisplayName(in.nextString());
break;
case "lastLoginTimestamp":
user.setLastLogin(new Date(in.nextLong() * 1000));
break;
case "avatar":
if(in.peek() == JsonReader.Token.NULL)
in.skipValue();
else
readAvatar(in, user, name);
break;
default:
Log.w(TAG, "Unknown value in user json: " + name);
in.skipValue();
break;
}
}
in.endObject();
return user;
}
示例11: fromJson
import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@Override
public Status fromJson(JsonReader in) throws IOException {
if (in.peek() == JsonReader.Token.NULL) {
in.nextNull();
return null;
}
final NullableJsonReader reader = new NullableJsonReader(in);
final Status status = new Status();
in.beginObject();
while (in.hasNext()) {
String name = in.nextName();
switch (name) {
case "version":
status.setVersion(reader.nextString());
break;
case "warnings":
case "issues":
// this is called warnings in api v1-2, issues in api v2
readWarnings(in, status);
break;
case "user":
status.setUser(new UserTypeAdapter().fromJson(in));
break;
default:
Log.w(TAG, "Unknown value in status json: " + name);
in.skipValue();
break;
}
}
in.endObject();
return status;
}
示例12: 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;
}
示例13: fromJson
import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@Override
public Error fromJson(JsonReader reader) throws IOException {
Error err = new Error();
reader.beginObject();
while (reader.hasNext()) {
switch (reader.nextName()) {
case "id":
err.setId(nextNullableString(reader));
break;
case "status":
err.setStatus(nextNullableString(reader));
break;
case "code":
err.setCode(nextNullableString(reader));
break;
case "title":
err.setTitle(nextNullableString(reader));
break;
case "detail":
err.setDetail(nextNullableString(reader));
break;
case "source":
err.setSource(nextNullableObject(reader, jsonBufferJsonAdapter));
break;
case "meta":
err.setMeta(nextNullableObject(reader, jsonBufferJsonAdapter));
break;
case "links":
err.setLinks(nextNullableObject(reader, jsonBufferJsonAdapter));
break;
default:
reader.skipValue();
break;
}
}
reader.endObject();
return err;
}
示例14: 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;
}
示例15: fromJson
import com.squareup.moshi.JsonReader; //导入方法依赖的package包/类
@Override
public Feed fromJson(JsonReader in) throws IOException {
if (in.peek() == JsonReader.Token.NULL) {
in.nextNull();
return null;
}
final NullableJsonReader reader = new NullableJsonReader(in);
final Feed feed = new Feed();
in.beginObject();
while (in.hasNext()) {
String name = in.nextName();
switch (name) {
case "id":
feed.setId(in.nextLong());
break;
case "url":
feed.setUrl(reader.nextString());
break;
case "link":
feed.setLink(reader.nextString());
break;
case "faviconLink":
String faviconLink = reader.nextString();
if (faviconLink != null && TextUtils.getTrimmedLength(faviconLink) == 0)
faviconLink = null;
feed.setFaviconLink(faviconLink);
break;
// title in API v1-2, name in API v2
case "title":
case "name":
feed.setName(StringUtils.cleanString(in.nextString()));
break;
case "added":
in.skipValue();
break;
case "folderId":
feed.setFolderId(in.nextLong());
break;
case "unreadCount":
// skip unreadCount, calculated later in SyncService
in.skipValue();
break;
case "ordering":
// createFeed returns a feed with ordering set to NULL
feed.setOrdering(reader.nextInt(0));
break;
case "pinned":
// createFeed returns a feed with pinned set to NULL
feed.setPinned(reader.nextBoolean(false));
break;
case "updateErrorCount":
feed.setUpdateErrorCount(reader.nextInt(0));
break;
case "lastUpdateError":
feed.setLastUpdateError(reader.nextString());
break;
case "error":
parseError(reader, feed);
break;
default:
Log.w(TAG, "Unknown value in feed json: " + name);
in.skipValue();
break;
}
}
in.endObject();
return feed;
}