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


Java JsonNumber.intValue方法代碼示例

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


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

示例1: toJavaObject

import javax.json.JsonNumber; //導入方法依賴的package包/類
/**
 * Converts a {@link JsonValue} to its corresponding Java object. Values of type {@link
 * JsonObject} or {@link JsonArray} are converted as specified by {@link #toJavaMap} and {@link
 * #toJavaList}, respectively.
 */
@Nullable
public static Object toJavaObject(JsonValue value) {
  switch (value.getValueType()) {
    case ARRAY:
      return toJavaList((JsonArray) value);
    case FALSE:
      return Boolean.FALSE;
    case NULL:
      return null;
    case NUMBER:
      JsonNumber number = (JsonNumber) value;
      return number.isIntegral() ? number.intValue() : number.doubleValue();
    case OBJECT:
      return toJavaMap((JsonObject) value);
    case STRING:
      return ((JsonString) value).getString();
    case TRUE:
      return Boolean.TRUE;
    default:
      throw new VerifyException("Json value with unknown type: " + value);
  }
}
 
開發者ID:google,項目名稱:devtools-driver,代碼行數:28,代碼來源:JavaxJson.java

示例2: fromJSON

import javax.json.JsonNumber; //導入方法依賴的package包/類
public static SessionRating fromJSON(JsonObject sessionRatingJson) {
	String id = getStringFromJson("id", sessionRatingJson);
	String session = getStringFromJson("session", sessionRatingJson);
	String attendeeId = getStringFromJson("attendeeId", sessionRatingJson);
	String _rev = getStringFromJson("_rev", sessionRatingJson);
	String _id = getStringFromJson("_id", sessionRatingJson);
	int rating = 0;
	if (sessionRatingJson.containsKey("rating")) {
		JsonNumber ratingJson = sessionRatingJson.getJsonNumber("rating");
		if (ratingJson != null) {
			rating = ratingJson.intValue();
		}
	}
	
    SessionRating sessionRating = new SessionRating(id, session, attendeeId, rating, _id, _rev);
    return sessionRating;
}
 
開發者ID:eclipse,項目名稱:microprofile-conference,代碼行數:18,代碼來源:SessionRating.java

示例3: getIntvalue

import javax.json.JsonNumber; //導入方法依賴的package包/類
/**
    * Returns the int value for a name
    * @param name
    * @return the value
    */
   public int getIntvalue(String name) {
if (name == null) {
    throw new NullPointerException("name is null!");
}

if (isInvalidJsonStream()) {
    return -1;
}

try {
    JsonReader reader = Json.createReader(new StringReader(jsonResult));
    JsonStructure jsonst = reader.read();

    JsonObject object = (JsonObject) jsonst;
    JsonNumber value = (JsonNumber) object.get(name);
    
    if (value == null) {
        return -1;
    }
    
    return value.intValue();
} catch (Exception e) {
    this.parseException = e;
    return -1;
}
   }
 
開發者ID:kawansoft,項目名稱:aceql-http,代碼行數:32,代碼來源:ResultAnalyzer.java

示例4: getErrorType

import javax.json.JsonNumber; //導入方法依賴的package包/類
/**
    * Returns the error_type in case of failure
    * @return the error_type in case of failure, -1 if no error
    */
   public int getErrorType() {

if (isInvalidJsonStream()) {
    return 0;
}

try {
    JsonReader reader = Json.createReader(new StringReader(jsonResult));
    JsonStructure jsonst = reader.read();

    JsonObject object = (JsonObject) jsonst;
    JsonString status = (JsonString) object.get("status");

    if (status == null) {
        return -1;
    }
    
    JsonNumber errorType = (JsonNumber) object.get("error_type");
    
    if (errorType == null) {
        return -1;
    }
    else {
        return errorType.intValue();
    }
} catch (Exception e) {
    this.parseException = e;
    return -1;
}


   }
 
開發者ID:kawansoft,項目名稱:aceql-http,代碼行數:37,代碼來源:ResultAnalyzer.java

示例5: getSex

import javax.json.JsonNumber; //導入方法依賴的package包/類
public ULoginUser.Sex getSex(JsonObject obj){
    JsonNumber sexNum = obj.getJsonNumber("sex");
    if(sexNum==null){
        return null;
    }
    int i = sexNum.intValue();
    if(i<0||i>3){
        return null;
    }
    return ULoginUser.Sex.values()[i];
}
 
開發者ID:dmrzh,項目名稱:ulogin_spring_security,代碼行數:12,代碼來源:UloginAuthentifiactionProvider.java

示例6: decode

import javax.json.JsonNumber; //導入方法依賴的package包/類
/**
 * IdTokenのデコード
 * 
 * @return IdTokenObject
 * @throws DataFormatException
 */
public IdTokenObject decode() throws DataFormatException {

  HashMap<String, String> idToken = this.splitIdToken();

  // Header
  String jsonHeader = idToken.get("header");

  JsonReader jsonHeaderReader = Json.createReader(new StringReader(jsonHeader));
  JsonObject rootHeader = jsonHeaderReader.readObject();
  jsonHeaderReader.close();

  JsonString typeString = rootHeader.getJsonString("typ");
  String type = typeString.getString();

  JsonString algorithmString = rootHeader.getJsonString("alg");
  String algorithm = algorithmString.getString();

  // Payload
  String jsonPayload = idToken.get("payload");

  JsonReader jsonPayloadReader = Json.createReader(new StringReader(jsonPayload));

  JsonObject rootPayload = jsonPayloadReader.readObject();
  jsonPayloadReader.close();

  JsonString issString = rootPayload.getJsonString("iss");
  String iss = issString.getString();

  JsonString userIdString = rootPayload.getJsonString("user_id");
  String userId = userIdString.getString();

  JsonString audString = rootPayload.getJsonString("aud");
  ArrayList<String> aud = new ArrayList<String>();
  aud.add(audString.getString());

  JsonNumber expString = rootPayload.getJsonNumber("exp");
  int exp = expString.intValue();

  JsonNumber iatString = rootPayload.getJsonNumber("iat");
  int iat = iatString.intValue();

  JsonString nonceString = rootPayload.getJsonString("nonce");
  String nonce = nonceString.getString();

  // signature
  String signature = idToken.get("signature");

  // デコードした値を格納
  return new IdTokenObject(type, algorithm, iss, userId, aud, nonce, exp, iat, signature);
}
 
開發者ID:yahoojapan,項目名稱:yconnect-servlet-sdk,代碼行數:57,代碼來源:IdTokenDecoder.java


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