本文整理匯總了Java中com.google.gson.stream.JsonToken.END_OBJECT屬性的典型用法代碼示例。如果您正苦於以下問題:Java JsonToken.END_OBJECT屬性的具體用法?Java JsonToken.END_OBJECT怎麽用?Java JsonToken.END_OBJECT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.google.gson.stream.JsonToken
的用法示例。
在下文中一共展示了JsonToken.END_OBJECT屬性的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: read
@Override public AnInterface read(JsonReader jsonReader) throws IOException {
jsonReader.beginObject();
String name = null;
while (jsonReader.peek() != JsonToken.END_OBJECT) {
switch (jsonReader.nextName()) {
case "name":
name = jsonReader.nextString();
break;
}
}
jsonReader.endObject();
return new AnImplementation(name);
}
示例2: peek
@Override
public JsonToken peek() throws IOException {
JsonToken token = null;
if (state() == State.INITIAL || state() == State.SCOPE_DOCUMENT) {
advance();
token = toGsonToken(delegate.getCurrentBsonType());
} else if (state() == State.TYPE) {
advance();
token = toGsonToken(delegate.getCurrentBsonType());
} else if (state() == State.NAME) {
token = JsonToken.NAME;
} else if (state() == State.END_OF_DOCUMENT) {
token = JsonToken.END_OBJECT;
} else if (state() == State.END_OF_ARRAY) {
token = JsonToken.END_ARRAY;
} else if (state() == State.DONE) {
token = JsonToken.END_DOCUMENT;
} else if (state() == State.VALUE) {
token = toGsonToken(delegate.getCurrentBsonType());
}
if (token == null) {
throw new IllegalStateException("Shouldn't get here (null token). Last state is " + state() + " currentType:" +
delegate.getCurrentBsonType());
}
return token;
}
示例3: toGsonToken
private static JsonToken toGsonToken(com.fasterxml.jackson.core.JsonToken token) {
switch (token) {
case START_ARRAY:
return JsonToken.BEGIN_ARRAY;
case END_ARRAY:
return JsonToken.END_ARRAY;
case START_OBJECT:
return JsonToken.BEGIN_OBJECT;
case END_OBJECT:
return JsonToken.END_OBJECT;
case FIELD_NAME:
return JsonToken.NAME;
case VALUE_FALSE:
return JsonToken.BOOLEAN;
case VALUE_TRUE:
return JsonToken.BOOLEAN;
case VALUE_NULL:
return JsonToken.NULL;
case VALUE_NUMBER_INT:
return JsonToken.NUMBER;
case VALUE_NUMBER_FLOAT:
return JsonToken.NUMBER;
case VALUE_STRING:
case VALUE_EMBEDDED_OBJECT:
return JsonToken.STRING;
default: // Not semantically equivalent
return JsonToken.NULL;
}
}
示例4: read
public Calendar read(JsonReader in) throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
return null;
}
in.beginObject();
int year = 0;
int month = 0;
int dayOfMonth = 0;
int hourOfDay = 0;
int minute = 0;
int second = 0;
while (in.peek() != JsonToken.END_OBJECT) {
String name = in.nextName();
int value = in.nextInt();
if (YEAR.equals(name)) {
year = value;
} else if (MONTH.equals(name)) {
month = value;
} else if (DAY_OF_MONTH.equals(name)) {
dayOfMonth = value;
} else if (HOUR_OF_DAY.equals(name)) {
hourOfDay = value;
} else if (MINUTE.equals(name)) {
minute = value;
} else if (SECOND.equals(name)) {
second = value;
}
}
in.endObject();
return new GregorianCalendar(year, month, dayOfMonth, hourOfDay, minute, second);
}
示例5: read
@Override
public Calendar read(JsonReader in) throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
return null;
}
in.beginObject();
int year = 0;
int month = 0;
int dayOfMonth = 0;
int hourOfDay = 0;
int minute = 0;
int second = 0;
while (in.peek() != JsonToken.END_OBJECT) {
String name = in.nextName();
int value = in.nextInt();
if (YEAR.equals(name)) {
year = value;
} else if (MONTH.equals(name)) {
month = value;
} else if (DAY_OF_MONTH.equals(name)) {
dayOfMonth = value;
} else if (HOUR_OF_DAY.equals(name)) {
hourOfDay = value;
} else if (MINUTE.equals(name)) {
minute = value;
} else if (SECOND.equals(name)) {
second = value;
}
}
in.endObject();
return new GregorianCalendar(year, month, dayOfMonth, hourOfDay, minute, second);
}
示例6: read
public Calendar read(JsonReader in) throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
return null;
}
in.beginObject();
int year = 0;
int month = 0;
int dayOfMonth = 0;
int hourOfDay = 0;
int minute = 0;
int second = 0;
while (in.peek() != JsonToken.END_OBJECT) {
String name = in.nextName();
int value = in.nextInt();
if ("year".equals(name)) {
year = value;
} else if ("month".equals(name)) {
month = value;
} else if (DAY_OF_MONTH.equals(name)) {
dayOfMonth = value;
} else if (HOUR_OF_DAY.equals(name)) {
hourOfDay = value;
} else if ("minute".equals(name)) {
minute = value;
} else if (SECOND.equals(name)) {
second = value;
}
}
in.endObject();
return new GregorianCalendar(year, month, dayOfMonth, hourOfDay, minute, second);
}
示例7: hasNext
public boolean hasNext() throws IOException {
JsonToken token = peek();
return (token == JsonToken.END_OBJECT || token == JsonToken.END_ARRAY) ? false : true;
}
示例8: peek
public JsonToken peek() throws IOException {
if (this.stack.isEmpty()) {
return JsonToken.END_DOCUMENT;
}
Iterator<?> o = peekStack();
if (o instanceof Iterator) {
boolean isObject = this.stack.get(this.stack.size() - 2) instanceof JsonObject;
Iterator<?> iterator = o;
if (!iterator.hasNext()) {
return isObject ? JsonToken.END_OBJECT : JsonToken.END_ARRAY;
} else {
if (isObject) {
return JsonToken.NAME;
}
this.stack.add(iterator.next());
return peek();
}
} else if (o instanceof JsonObject) {
return JsonToken.BEGIN_OBJECT;
} else {
if (o instanceof JsonArray) {
return JsonToken.BEGIN_ARRAY;
}
if (o instanceof JsonPrimitive) {
JsonPrimitive primitive = (JsonPrimitive) o;
if (primitive.isString()) {
return JsonToken.STRING;
}
if (primitive.isBoolean()) {
return JsonToken.BOOLEAN;
}
if (primitive.isNumber()) {
return JsonToken.NUMBER;
}
throw new AssertionError();
} else if (o instanceof JsonNull) {
return JsonToken.NULL;
} else {
if (o == SENTINEL_CLOSED) {
throw new IllegalStateException("JsonReader is closed");
}
throw new AssertionError();
}
}
}
示例9: hasNext
@Override public boolean hasNext() throws IOException {
JsonToken token = peek();
return token != JsonToken.END_OBJECT && token != JsonToken.END_ARRAY;
}
示例10: peek
@Override public JsonToken peek() throws IOException {
if (stack.isEmpty()) {
return JsonToken.END_DOCUMENT;
}
Object o = peekStack();
if (o instanceof Iterator) {
boolean isObject = stack.get(stack.size() - 2) instanceof JsonObject;
Iterator<?> iterator = (Iterator<?>) o;
if (iterator.hasNext()) {
if (isObject) {
return JsonToken.NAME;
} else {
stack.add(iterator.next());
return peek();
}
} else {
return isObject ? JsonToken.END_OBJECT : JsonToken.END_ARRAY;
}
} else if (o instanceof JsonObject) {
return JsonToken.BEGIN_OBJECT;
} else if (o instanceof JsonArray) {
return JsonToken.BEGIN_ARRAY;
} else if (o instanceof JsonPrimitive) {
JsonPrimitive primitive = (JsonPrimitive) o;
if (primitive.isString()) {
return JsonToken.STRING;
} else if (primitive.isBoolean()) {
return JsonToken.BOOLEAN;
} else if (primitive.isNumber()) {
return JsonToken.NUMBER;
} else {
throw new AssertionError();
}
} else if (o instanceof JsonNull) {
return JsonToken.NULL;
} else if (o == SENTINEL_CLOSED) {
throw new IllegalStateException("JsonReader is closed");
} else {
throw new AssertionError();
}
}
示例11: readMessage
public static <T> int readMessage(JsonReader reader,String tableName,Class<T> clazz,long last_sync_ts) throws IOException, JSONException,Exception {
String n = null;
int i=0;
while (reader.hasNext()) {
JsonToken peek=reader.peek();
String v = null;
if (peek==JsonToken.BEGIN_OBJECT) {
reader.beginObject();
} else if (peek==JsonToken.NAME) {
n=reader.nextName();
} else if (peek==JsonToken.BEGIN_ARRAY) {
if (n.equals(tableName)) {
i=readJsnArr(reader,tableName,clazz);
} else {
if (n.equals("params")) {
reader.beginArray();
if (reader.hasNext()) {
reader.beginObject();
if (reader.hasNext()) {
n=reader.nextName();
v=reader.nextString();
}
reader.endObject();
}
reader.endArray();
} else {
reader.skipValue();
}
}
} else if (peek==JsonToken.END_OBJECT) {
reader.endObject();
} else if (peek==JsonToken.END_ARRAY) {
reader.endArray();
} else if (peek==JsonToken.STRING) {
reader.skipValue();
} else {
reader.skipValue();
}
}
return i;
}