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


Java JsonReader.nextString方法代码示例

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


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

示例1: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public java.sql.Date read(JsonReader in) throws IOException {
    switch (in.peek()) {
        case NULL:
            in.nextNull();
            return null;
        default:
            String date = in.nextString();
            try {
                if (dateFormat != null) {
                    return new java.sql.Date(dateFormat.parse(date).getTime());
                }
                return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
            } catch (ParseException e) {
                throw new JsonParseException(e);
            }
    }
}
 
开发者ID:cliffano,项目名称:swaggy-jenkins,代码行数:19,代码来源:JSON.java

示例2: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
public Locale read(JsonReader in) throws IOException {
    if (in.peek() == JsonToken.NULL) {
        in.nextNull();
        return null;
    }
    StringTokenizer tokenizer = new StringTokenizer(in.nextString(), EventsFilesManager.ROLL_OVER_FILE_NAME_SEPARATOR);
    String language = null;
    String country = null;
    String variant = null;
    if (tokenizer.hasMoreElements()) {
        language = tokenizer.nextToken();
    }
    if (tokenizer.hasMoreElements()) {
        country = tokenizer.nextToken();
    }
    if (tokenizer.hasMoreElements()) {
        variant = tokenizer.nextToken();
    }
    if (country == null && variant == null) {
        return new Locale(language);
    }
    if (variant == null) {
        return new Locale(language, country);
    }
    return new Locale(language, country, variant);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:27,代码来源:TypeAdapters.java

示例3: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public StringBuilder read(JsonReader in) throws IOException {
  if (in.peek() == JsonToken.NULL) {
    in.nextNull();
    return null;
  }
  return new StringBuilder(in.nextString());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:TypeAdapters.java

示例4: gson

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Benchmark
public void gson(Blackhole bh) throws Exception {
	JsonReader reader = new JsonReader(new CharArrayReader(chars));
	while (true) {
		JsonToken token = reader.peek();
		switch (token) {
		case BEGIN_ARRAY:
			reader.beginArray();
			break;
		case END_ARRAY:
			reader.endArray();
			break;
		case BEGIN_OBJECT:
			reader.beginObject();
			break;
		case END_OBJECT:
			reader.endObject();
			break;
		case NAME:
			reader.nextName();
			break;
		case STRING:
			reader.nextString();
			break;
		case NUMBER:
			reader.nextString();
			break;
		case BOOLEAN:
			reader.nextBoolean();
			break;
		case NULL:
			reader.nextNull();
			break;
		case END_DOCUMENT:
			reader.close();
			return;
		}
	}
}
 
开发者ID:httpdigest,项目名称:ftljson,代码行数:40,代码来源:B.java

示例5: readNext

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
protected String readNext(final String name, final JsonReader reader) throws IOException {
    if(reader.peek() != JsonToken.NULL) {
        return reader.nextString();
    }
    else {
        reader.skipValue();
        log.warn(String.format("No value for key %s", name));
        return null;
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:11,代码来源:JsonBookmarkCollection.java

示例6: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public PlayerId read(JsonReader in) throws IOException {
    in.beginArray();
    String player_id = in.nextString();
    String username = in.nextString();
    String _id = in.nextString();
    in.endArray();

    return new SimplePlayerId(_id, player_id, username);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:11,代码来源:PlayerIdTypeAdapter.java

示例7: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public DOrderAction read(JsonReader reader) throws IOException {
    if (reader.peek() == JsonToken.NULL) {
        reader.nextNull();
        return null;
    }
    String value = reader.nextString();

    return DOrderAction.getOrderByValue(value);

}
 
开发者ID:indiketa,项目名称:degiro-java-client,代码行数:12,代码来源:DUtils.java

示例8: parseResponse

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
/**
 * 太绕,还是直接用Json解析吧
 *
 * @param response
 * @throws IOException
 */
private void parseResponse(Reader response) throws IOException {
    JsonReader reader = new JsonReader(response);
    reader.beginObject();
    String name;
    while (reader.hasNext()) {
        name = reader.nextName();
        if (TextUtils.equals(Field.ERROR, name)) {
            reader.nextInt();
        } else if (TextUtils.equals(Field.MESSAGE, name)) {
            reader.nextString();
        } else if (TextUtils.equals(Field.DATA, name)) {
            reader.beginObject();
            while (reader.hasNext()) {
                reader.nextName();
                reader.beginArray();
                while (reader.hasNext()) {
                    reader.beginObject();
                    String itemObjKey;
                    while (reader.hasNext()) {
                        itemObjKey = reader.nextName();
                        if (TextUtils.equals(Field.TOKEN, itemObjKey)) {
                            reader.nextString();
                        } else {
                            reader.skipValue();
                        }
                    }
                    reader.endObject();
                }
                reader.endArray();
            }
            reader.endObject();
        } else {
            reader.skipValue();
        }
    }
    reader.endObject();
    reader.close();
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:45,代码来源:TicketDetailPresenter.java

示例9: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public DateTime read(JsonReader in) throws IOException {
  switch (in.peek()) {
    case NULL:
      in.nextNull();
      return null;
    default:
      String date = in.nextString();
      return parseFormatter.parseDateTime(date);
  }
}
 
开发者ID:ARMmbed,项目名称:mbed-cloud-sdk-java,代码行数:12,代码来源:ApiClient.java

示例10: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public String read(JsonReader in) throws IOException {
    if (in.peek() == JsonToken.NULL) {
        in.nextNull();
        return "";
    }
    return in.nextString();
}
 
开发者ID:rascarlo,项目名称:AURdroid,代码行数:9,代码来源:AurRpcService.java

示例11: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public URI read(JsonReader in) throws IOException {
  if (in.peek() == JsonToken.NULL) {
    in.nextNull();
    return null;
  }
  try {
    String nextString = in.nextString();
    return "null".equals(nextString) ? null : new URI(nextString);
  } catch (URISyntaxException e) {
    throw new JsonIOException(e);
  }
}
 
开发者ID:odoo-mobile-intern,项目名称:odoo-work,代码行数:14,代码来源:TypeAdapters.java

示例12: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public TransactionID read(JsonReader in) throws IOException {
    return new TransactionID(in.nextString());
}
 
开发者ID:oanda,项目名称:v20-java,代码行数:5,代码来源:TransactionID.java

示例13: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public ObjectEnum read(final JsonReader jsonReader) throws IOException {
  String value = jsonReader.nextString();
  return ObjectEnum.fromValue(String.valueOf(value));
}
 
开发者ID:ARMmbed,项目名称:mbed-cloud-sdk-java,代码行数:6,代码来源:GroupSummary.java

示例14: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public OrderSpecifier read(JsonReader in) throws IOException {
    return new OrderSpecifier(in.nextString());
}
 
开发者ID:oanda,项目名称:v20-java,代码行数:5,代码来源:OrderSpecifier.java

示例15: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
        public T read(JsonReader in) throws IOException {
            Object res;
            in.beginObject();
            LOG.info(in.nextName());
            String clazzName = in.nextString();
            LOG.info(clazzName);
            LOG.info(in.nextName());
            try {
                Class<?> typeOfT = Class.forName(clazzName);
//                 TypeAdapter<?> del = gson.getDelegateAdapter(new ObjectTypeAdapterFactory(),
//                 );
                TypeAdapter<?> del = gson.getAdapter(TypeToken.get(typeOfT));
                LOG.info("ta: " + del + " taDel: " + delegate + " tt: " + TypeToken.get(typeOfT));
                if (typeOfT.isArray()) {
                    del = com.google.gson.internal.bind.ArrayTypeAdapter.FACTORY.create(gson, TypeToken.get(typeOfT));
                } else {
                    del = delegate; 
                }
                
                JsonToken peek = in.peek();
                switch (peek) {
                    case STRING:
                        res = in.nextString();
                        break;
                    case BOOLEAN:
                        res = in.nextBoolean();
                        break;
                    case NUMBER:
                        if (Long.class.equals(typeOfT)) {
                            res = in.nextLong();
                        } else if (Integer.class.equals(typeOfT)) {
                            res = in.nextInt();
                        } else {
                            res = in.nextDouble();
                        }
                        break;

                    default:
                        res = (T) del.read(in);
                }

            } catch (ClassNotFoundException e) {
                throw new JsonParseException(e);
            }
            // res = delegate.read(in);
            in.endObject();
            return (T) res;
        }
 
开发者ID:sap-nocops,项目名称:Jerkoff,代码行数:50,代码来源:ObjectTypeAdapterFactory.java


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