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


Java JsonParser.getIntValue方法代碼示例

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


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

示例1: _parseBooleanPrimitive

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
protected final boolean _parseBooleanPrimitive(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if (localJsonToken == JsonToken.VALUE_TRUE);
  while (true)
  {
    return true;
    if (localJsonToken == JsonToken.VALUE_FALSE)
      return false;
    if (localJsonToken == JsonToken.VALUE_NULL)
      return false;
    if (localJsonToken == JsonToken.VALUE_NUMBER_INT)
      if (paramJsonParser.getIntValue() == 0)
        return false;
    if (localJsonToken != JsonToken.VALUE_STRING)
      break;
    String str = paramJsonParser.getText().trim();
    if ("true".equals(str))
      continue;
    if (("false".equals(str)) || (str.length() == 0))
      return Boolean.FALSE.booleanValue();
    throw paramDeserializationContext.weirdStringException(this._valueClass, "only \"true\" or \"false\" recognized");
  }
  throw paramDeserializationContext.mappingException(this._valueClass);
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:27,代碼來源:StdDeserializer.java

示例2: deserialize

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
public Character deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if (localJsonToken == JsonToken.VALUE_NUMBER_INT)
  {
    int i = paramJsonParser.getIntValue();
    if ((i >= 0) && (i <= 65535))
      return Character.valueOf((char)i);
  }
  else if (localJsonToken == JsonToken.VALUE_STRING)
  {
    String str = paramJsonParser.getText();
    if (str.length() == 1)
      return Character.valueOf(str.charAt(0));
  }
  throw paramDeserializationContext.mappingException(this._valueClass);
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:19,代碼來源:StdDeserializer.java

示例3: deserialize

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
public Enum<?> deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if (localJsonToken == JsonToken.VALUE_STRING)
  {
    String str = paramJsonParser.getText();
    Enum localEnum2 = this._resolver.findEnum(str);
    if (localEnum2 == null)
      throw paramDeserializationContext.weirdStringException(this._resolver.getEnumClass(), "value not one of declared Enum instance names");
    return localEnum2;
  }
  if (localJsonToken == JsonToken.VALUE_NUMBER_INT)
  {
    if (paramDeserializationContext.isEnabled(DeserializationConfig.Feature.FAIL_ON_NUMBERS_FOR_ENUMS))
      throw paramDeserializationContext.mappingException("Not allowed to deserialize Enum value out of JSON number (disable DeserializationConfig.Feature.FAIL_ON_NUMBERS_FOR_ENUMS to allow)");
    int i = paramJsonParser.getIntValue();
    Enum localEnum1 = this._resolver.getEnum(i);
    if (localEnum1 == null)
      throw paramDeserializationContext.weirdNumberException(this._resolver.getEnumClass(), "index value outside legal index range [0.." + this._resolver.lastValidIndex() + "]");
    return localEnum1;
  }
  throw paramDeserializationContext.mappingException(this._resolver.getEnumClass());
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:25,代碼來源:EnumDeserializer.java

示例4: _parseBoolean

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
protected final Boolean _parseBoolean(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if (localJsonToken == JsonToken.VALUE_TRUE)
    return Boolean.TRUE;
  if (localJsonToken == JsonToken.VALUE_FALSE)
    return Boolean.FALSE;
  if (localJsonToken == JsonToken.VALUE_NULL)
    return null;
  if (localJsonToken == JsonToken.VALUE_NUMBER_INT)
  {
    if (paramJsonParser.getIntValue() == 0)
      return Boolean.FALSE;
    return Boolean.TRUE;
  }
  if (localJsonToken == JsonToken.VALUE_STRING)
  {
    String str = paramJsonParser.getText().trim();
    if ("true".equals(str))
      return Boolean.TRUE;
    if (("false".equals(str)) || (str.length() == 0))
      return Boolean.FALSE;
    throw paramDeserializationContext.weirdStringException(this._valueClass, "only \"true\" or \"false\" recognized");
  }
  throw paramDeserializationContext.mappingException(this._valueClass);
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:28,代碼來源:StdDeserializer.java

示例5: deserialize

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
@Override
public DangerLevel deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
    int dangerLevel = jp.getIntValue();
    return DangerLevel.valueOf("LEVEL" + dangerLevel);
}
 
開發者ID:JonathanGeoffroy,項目名稱:LifeMonitor,代碼行數:6,代碼來源:DangerLevelDeserializer.java

示例6: parseBackendResponse

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
private static BackendResponse parseBackendResponse(JsonParser parser) throws IOException {
    try {
        // Sanity check: verify that we got "Json Object":
        if (parser.nextToken() != JsonToken.START_OBJECT) {
            throw new IOException("Expected data to start with an Object");
        }
        long responseKey = 0;
        int delay = 0;
        int numItems = 0;
        int itemSize = 0;
        String[] items = null;
        JsonToken current;

        while (parser.nextToken() != JsonToken.END_OBJECT) {
            String fieldName = parser.getCurrentName();
            // advance
            current = parser.nextToken();
            if (fieldName.equals("responseKey")) {
                responseKey = parser.getLongValue();
            } else if (fieldName.equals("delay")) {
                delay = parser.getIntValue();
            } else if (fieldName.equals("itemSize")) {
                itemSize = parser.getIntValue();
            } else if (fieldName.equals("numItems")) {
                numItems = parser.getIntValue();
            } else if (fieldName.equals("items")) {
                // expect numItems to be populated before hitting this
                if (numItems == 0) {
                    throw new IllegalStateException("Expected numItems > 0");
                }
                items = new String[numItems];
                if (current == JsonToken.START_ARRAY) {
                    int j = 0;
                    // For each of the records in the array
                    while (parser.nextToken() != JsonToken.END_ARRAY) {
                        items[j++] = parser.getText();
                    }
                } else {
                    //                            System.out.println("Error: items should be an array: skipping.");
                    parser.skipChildren();
                }

            }
        }
        return new BackendResponse(responseKey, delay, numItems, itemSize, items);
    } finally {
        parser.close();
    }
}
 
開發者ID:Netflix,項目名稱:ReactiveLab,代碼行數:50,代碼來源:BackendResponse.java

示例7: parseUser

import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
private static User parseUser(HipChat origin, ObjectMapper mapper, JsonParser jp) throws JsonParseException, JsonMappingException, IOException
{
    User result = null;

    String userId = null;
    String name = null;
    String email = null;
    String title = null;
    String password = null;
    String photoUrl = null;
    String status = null;
    String statusMessage = null;
    boolean isGroupAdmin = false;

    while (jp.nextToken() != JsonToken.END_OBJECT)
    {
        String tag = jp.getText();
        jp.nextToken();
        if ("user_id".equals(tag))
        {
            userId = UtilParser.parseString(jp);
        } else if ("name".equals(tag))
        {
            name = UtilParser.parseString(jp);
        } else if ("email".equals(tag))
        {
            email = UtilParser.parseString(jp);
        } else if ("title".equals(tag))
        {
            title = UtilParser.parseString(jp);
        } else if ("is_group_admin".equals(tag))
        {
            int admin = jp.getIntValue();
            isGroupAdmin = (admin == 1);
        } else if ("password".equals(tag))
        {
            password = UtilParser.parseString(jp);
        } else if ("photo_url".equals(tag))
        {
            photoUrl = UtilParser.parseString(jp);
        } else if ("status".equals(tag))
        {
            status = UtilParser.parseString(jp);
        } else if ("status_message".equals(tag))
        {
            statusMessage = UtilParser.parseString(jp);
        }
    }

    result = User.create(userId, name, email, title, photoUrl, password, status, statusMessage, isGroupAdmin);

    return result;
}
 
開發者ID:blazsolar,項目名稱:gradle-hipchat-plugin,代碼行數:54,代碼來源:UserParser.java


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