當前位置: 首頁>>代碼示例>>Java>>正文


Java DeserializationContext.wrongTokenException方法代碼示例

本文整理匯總了Java中org.codehaus.jackson.map.DeserializationContext.wrongTokenException方法的典型用法代碼示例。如果您正苦於以下問題:Java DeserializationContext.wrongTokenException方法的具體用法?Java DeserializationContext.wrongTokenException怎麽用?Java DeserializationContext.wrongTokenException使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.codehaus.jackson.map.DeserializationContext的用法示例。


在下文中一共展示了DeserializationContext.wrongTokenException方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: _deserialize

import org.codehaus.jackson.map.DeserializationContext; //導入方法依賴的package包/類
private final Object _deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  Object localObject = _findDeserializer(paramDeserializationContext, _locateTypeId(paramJsonParser, paramDeserializationContext)).deserialize(paramJsonParser, paramDeserializationContext);
  if (paramJsonParser.nextToken() != JsonToken.END_ARRAY)
    throw paramDeserializationContext.wrongTokenException(paramJsonParser, JsonToken.END_ARRAY, "expected closing END_ARRAY after type information and deserialized value");
  return localObject;
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:9,代碼來源:AsArrayTypeDeserializer.java

示例2: _locateTypeId

import org.codehaus.jackson.map.DeserializationContext; //導入方法依賴的package包/類
protected final String _locateTypeId(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  if (!paramJsonParser.isExpectedStartArrayToken())
    throw paramDeserializationContext.wrongTokenException(paramJsonParser, JsonToken.START_ARRAY, "need JSON Array to contain As.WRAPPER_ARRAY type information for class " + baseTypeName());
  if (paramJsonParser.nextToken() != JsonToken.VALUE_STRING)
    throw paramDeserializationContext.wrongTokenException(paramJsonParser, JsonToken.VALUE_STRING, "need JSON String that contains type id (for subtype of " + baseTypeName() + ")");
  String str = paramJsonParser.getText();
  paramJsonParser.nextToken();
  return str;
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:12,代碼來源:AsArrayTypeDeserializer.java

示例3: _deserialize

import org.codehaus.jackson.map.DeserializationContext; //導入方法依賴的package包/類
private final Object _deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  if (paramJsonParser.getCurrentToken() != JsonToken.START_OBJECT)
    throw paramDeserializationContext.wrongTokenException(paramJsonParser, JsonToken.START_OBJECT, "need JSON Object to contain As.WRAPPER_OBJECT type information for class " + baseTypeName());
  if (paramJsonParser.nextToken() != JsonToken.FIELD_NAME)
    throw paramDeserializationContext.wrongTokenException(paramJsonParser, JsonToken.FIELD_NAME, "need JSON String that contains type id (for subtype of " + baseTypeName() + ")");
  JsonDeserializer localJsonDeserializer = _findDeserializer(paramDeserializationContext, paramJsonParser.getText());
  paramJsonParser.nextToken();
  Object localObject = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext);
  if (paramJsonParser.nextToken() != JsonToken.END_OBJECT)
    throw paramDeserializationContext.wrongTokenException(paramJsonParser, JsonToken.END_OBJECT, "expected closing END_OBJECT after type information and deserialized value");
  return localObject;
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:15,代碼來源:AsWrapperTypeDeserializer.java

示例4: deserialize

import org.codehaus.jackson.map.DeserializationContext; //導入方法依賴的package包/類
@Override public CollectionPage<?> deserialize(final JsonParser jp,
                                               final DeserializationContext ctxt) throws IOException {
    final ObjectMapper codec = (ObjectMapper) jp.getCodec();

    final List<Object> objects = new ArrayList<Object>();
    final List<Link> links = new ArrayList<Link>();
    Integer total = null;

    JsonToken jsonToken = jp.getCurrentToken();

    if (START_OBJECT.equals(jsonToken)) {
        while (null != (jsonToken = jp.nextToken())) {
            if (FIELD_NAME.equals(jsonToken)) {
                final String currentName = jp.getCurrentName();
                if ("links".equals(currentName)) {
                    jsonToken = jp.nextToken();

                    if (START_ARRAY.equals(jsonToken)) {
                        while (START_OBJECT.equals(jp.nextToken())) {
                            links.add(codec.readValue(jp, Link.class));
                        }
                    }

                } else if ("total".equals(currentName)) {
                    jp.nextToken();
                    total = codec.readValue(jp, Integer.class);
                } else if ("values".equals(currentName)) {
                    jp.nextToken();

                    final Collection<Object> deserializedObjects = deserializeValues(jp, codec);
                    objects.addAll(deserializedObjects);
                }
            }
        }

        return new CollectionPage<Object>(objects,
                                          getSelf(links),
                                          getNextPage(links),
                                          getPreviousPage(links),
                                          total);
    }

    throw ctxt.wrongTokenException(jp, START_OBJECT, "Input JSON could not be deserialized to CollectionPage");
}
 
開發者ID:JohnDeere,項目名稱:MyJohnDeereAPI-OAuth-Java-Client,代碼行數:45,代碼來源:CollectionPageDeserializer.java


注:本文中的org.codehaus.jackson.map.DeserializationContext.wrongTokenException方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。