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


Java JsonToken.BEGIN_OBJECT属性代码示例

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


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

示例1: 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;
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:JsonParserReader.java

示例2: read

@Override
public ItemStack read(JsonReader in) throws IOException {
    if (in.peek() != JsonToken.BEGIN_OBJECT)
        return null;

    int id = 1;
    short data = 0;
    int amount = 1;
    ItemMeta meta = null;

    in.beginObject();
    while (in.hasNext()) {
        String name = in.nextName();
        switch (name) {
            case "id":
                id = in.nextInt();
                break;
            case "damage":
                data = (short) in.nextInt();
                break;
            case "amount":
                amount = in.nextInt();
                break;
            case "meta":
                meta = metaAdapter.read(in);
                break;
            default:
                Static.log("Unknown type, " + name);
        }
    }
    in.endObject();

    ItemStack item = new ItemStack(id, amount, data);
    if (meta != null)
        item.setItemMeta(meta);
    return item;
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:37,代码来源:ItemStackTypeAdapter.java

示例3: toGsonToken

private static JsonToken toGsonToken(BsonType type) {
  final JsonToken token;
  switch (type) {
    case END_OF_DOCUMENT:
      token = JsonToken.END_DOCUMENT;
      break;
    case DOUBLE:
      token = JsonToken.NUMBER;
      break;
    case STRING:
      token = JsonToken.STRING;
      break;
    case DOCUMENT:
      token = JsonToken.BEGIN_OBJECT;
      break;
    case ARRAY:
      token = JsonToken.BEGIN_ARRAY;
      break;
    case OBJECT_ID:
      token = JsonToken.STRING;
      break;
    case BOOLEAN:
      token = JsonToken.BOOLEAN;
      break;
    case DATE_TIME:
      token = JsonToken.NUMBER;
      break;
    case NULL:
      token = JsonToken.NULL;
      break;
    case REGULAR_EXPRESSION:
      token = JsonToken.STRING;
      break;
    case SYMBOL:
      token = JsonToken.STRING;
      break;
    case INT32:
      token = JsonToken.NUMBER;
      break;
    case INT64:
      token = JsonToken.NUMBER;
      break;
    case TIMESTAMP:
      token = JsonToken.NUMBER;
      break;
    case DECIMAL128:
      token = JsonToken.NUMBER;
      break;
    case BINARY:
      token = JsonToken.STRING;
      break;
    default:
      // not really sure what to do with this type
      token = JsonToken.NULL;
  }

  return token;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:58,代码来源:BsonReader.java

示例4: 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();
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:45,代码来源:JsonTreeReader.java

示例5: 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();
  }
}
 
开发者ID:odoo-mobile-intern,项目名称:odoo-work,代码行数:42,代码来源:JsonTreeReader.java

示例6: read

@Override
public Location read(JsonReader in) throws IOException {
    if (in.peek() != JsonToken.BEGIN_OBJECT)
        return null;

    World world = null;
    Double x = null;
    Double y = null;
    Double z = null;
    Double yaw = null;
    Double pitch = null;

    in.beginObject();
    while (in.hasNext()) {
        String name = in.nextName();
        switch (name) {
            case "world":
                world = Bukkit.getWorld(in.nextString());
                break;
            case "x":
                x = in.nextDouble();
                break;
            case "y":
                y = in.nextDouble();
                break;
            case "z":
                z = in.nextDouble();
                break;
            case "yaw":
                yaw = in.nextDouble();
                break;
            case "pitch":
                pitch = in.nextDouble();
                break;
            default:
                Static.log("Unknown type, " + name);
        }
    }
    in.endObject();

    return world != null && x != null && y != null && z != null &&
            pitch != null && yaw != null
            ? new Location(world, x, y, z, yaw.floatValue(), pitch.floatValue())
            : null;
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:45,代码来源:LocationTypeAdapter.java

示例7: read

@Override
public GUISignature read(JsonReader in) throws IOException {
    if (in.peek() != JsonToken.BEGIN_OBJECT)
        return null;

    GUISignature signature = new GUISignature();
    Map<String, Object> contents = new HashMap<>();
    in.beginObject();
    while (in.hasNext()) {
        String name = in.nextName();
        switch (name) {
            case "type":
                signature.type(InventoryType.valueOf(in.nextString()));
                break;
            case "title":
                signature.title(in.nextString());
                break;
            case "size":
                signature.size(in.nextInt());
                break;
            case "handlerIndexes":
                for (Number index : (Collection<Number>) collectionAdapter.read(in)) {
                    signature.addHandlerIndexes(index.intValue());
                }
                break;
            case "data":
                contents = mapAdapter.read(in);
                break;
            default:
                Static.log("Unknown type, " + name);
        }
    }

    for (Map.Entry<String, Object> entry : contents.entrySet()) {
        Integer key = Integer.parseInt(entry.getKey());
        Object value = entry.getValue();
        if (value instanceof Map) {
            signature.item(key, ConfigurationSerializableAdapter.deserialize((Map<String, Object>) entry.getValue()));
        } else {
            Number numVal = (Number) value;
            signature.item(key, signature.getContents().get(numVal.intValue()));
        }
    }
    in.endObject();

    return signature;
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:47,代码来源:GUISignatureTypeAdapter.java

示例8: 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;      
  }
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:44,代码来源:FlowzrSyncEngine.java


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