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


Java JsonString.getString方法代碼示例

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


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

示例1: createShibGroup

import javax.json.JsonString; //導入方法依賴的package包/類
@POST
@Path("shib")
public Response createShibGroup(JsonObject shibGroupInput) {
    String expectedNameKey = "name";
    JsonString name = shibGroupInput.getJsonString(expectedNameKey);
    if (name == null) {
        return errorResponse(Response.Status.BAD_REQUEST, "required field missing: " + expectedNameKey);
    }
    String expectedAttributeKey = "attribute";
    JsonString attribute = shibGroupInput.getJsonString(expectedAttributeKey);
    if (attribute == null) {
        return errorResponse(Response.Status.BAD_REQUEST, "required field missing: " + expectedAttributeKey);
    }
    String expectedPatternKey = "pattern";
    JsonString pattern = shibGroupInput.getJsonString(expectedPatternKey);
    if (pattern == null) {
        return errorResponse(Response.Status.BAD_REQUEST, "required field missing: " + expectedPatternKey);
    }
    ShibGroup shibGroupToPersist = new ShibGroup(name.getString(), attribute.getString(), pattern.getString(), shibGroupPrv);
    ShibGroup persitedShibGroup = shibGroupPrv.persist(shibGroupToPersist);
    if (persitedShibGroup != null) {
        return okResponse("Shibboleth group persisted: " + persitedShibGroup);
    } else {
        return errorResponse(Response.Status.BAD_REQUEST, "Could not persist Shibboleth group");
    }
}
 
開發者ID:pengchengluo,項目名稱:Peking-University-Open-Research-Data-Platform,代碼行數:27,代碼來源:Groups.java

示例2: fromJSON

import javax.json.JsonString; //導入方法依賴的package包/類
public static CouchID fromJSON(InputStream is) {
    JsonReader rdr = null;
    try {
        rdr = Json.createReader(is);
        JsonObject couchIDJson = rdr.readObject();

        JsonString idJson = couchIDJson.getJsonString("id");
        JsonString revJson = couchIDJson.getJsonString("rev");
        CouchID attendee = new CouchID(idJson.getString(), revJson.getString());
        return attendee;
    } finally {
        if (rdr != null) {
            rdr.close();
        }
    }

}
 
開發者ID:eclipse,項目名稱:microprofile-conference,代碼行數:18,代碼來源:CouchID.java

示例3: getString

import javax.json.JsonString; //導入方法依賴的package包/類
public static String getString( JsonObject o, String n, String defaultValue )
{
    JsonValue v = o.get( n );
    if( v == null ) {
        return defaultValue;
    }
    switch( v.getValueType() ) {
        case NUMBER:
            JsonNumber jn = (JsonNumber) v;
            return jn.toString();
        case STRING:
            JsonString s = (JsonString) v;
            return s.getString();
        case TRUE:
            return "true";
        case FALSE:
            return "false";
        case NULL:
            return defaultValue;
        default:
            return v.toString();
    }
}
 
開發者ID:peter-mount,項目名稱:opendata-common,代碼行數:24,代碼來源:JsonUtils.java

示例4: getEndPointUrl

import javax.json.JsonString; //導入方法依賴的package包/類
private String getEndPointUrl(ServletContextEvent e) {
       //if we're running in a cf, we should use the details from those environment vars.
       String vcap_application = System.getenv("VCAP_APPLICATION");
       if(vcap_application!=null){
           ServletContext sc = e.getServletContext();
           String contextPath = sc.getContextPath();

           JsonObject vcapApplication = Json.createReader(new StringReader(vcap_application)).readObject();
           JsonArray uris = vcapApplication.getJsonArray("application_uris");
           JsonString firstUriAsString = uris.getJsonString(0);
           endPointUrl = "ws://"+firstUriAsString.getString()+contextPath+"/room";
           System.out.println("Using CF details of "+endPointUrl);
       }else{
           System.out.println("This room is intended to obtain it's configuration from the CF environment");
           System.out.println("Assuming that this room is running on localhost port 9080 (this should match the config in server.xml)");
           endPointUrl = "ws://localhost:9080/room";
       }
	return endPointUrl;
}
 
開發者ID:ilanpillemer,項目名稱:real1ty,代碼行數:20,代碼來源:Config.java

示例5: getValue

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

if (isInvalidJsonStream()) {
    return null;
}

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

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

示例6: getStackTrace

import javax.json.JsonString; //導入方法依賴的package包/類
/**
    * Returns the stack_trace in case of failure
    * @return the stack_trace in case of failure, null if no stack_trace
    */
   public String getStackTrace() {

if (isInvalidJsonStream()) {
    return null;
}

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 null;
    }
    
    JsonString stackTrace = (JsonString) object.get("stack_trace");
    if (stackTrace == null) {
        return null;
    }
    else {
        return stackTrace.getString();
    }
} catch (Exception e) {
    this.parseException = e;
    return null;
}

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

示例7: getString

import javax.json.JsonString; //導入方法依賴的package包/類
public static String getString(String key, JsonObject json) {
   	String result = null;
	if (json.containsKey(key)) {
		JsonString value = json.getJsonString(key);
		if (value != null) {
			result = value.getString();
		}
	}
	return result;
}
 
開發者ID:samolisov,項目名稱:bluemix-liberty-microprofile-demo,代碼行數:11,代碼來源:JsonUtil.java

示例8: getStringProp

import javax.json.JsonString; //導入方法依賴的package包/類
private String getStringProp(JsonObject obj, String prop) {
    JsonString jsonString = obj.getJsonString(prop);
    if(jsonString==null){
        return null;
    }
    return jsonString.getString();
}
 
開發者ID:dmrzh,項目名稱:ulogin_spring_security,代碼行數:8,代碼來源:UloginAuthentifiactionProvider.java

示例9: getStringFromJson

import javax.json.JsonString; //導入方法依賴的package包/類
private static String getStringFromJson(String key, JsonObject json) {
   	String returnedString = null;
	if (json.containsKey(key)) {
		JsonString value = json.getJsonString(key);
		if (value != null) {
			returnedString = value.getString();
		}
	}
	return returnedString;
}
 
開發者ID:eclipse,項目名稱:microprofile-conference,代碼行數:11,代碼來源:SessionRating.java

示例10: getValue

import javax.json.JsonString; //導入方法依賴的package包/類
private static String getValue(JsonValue value) {
    if (value.getValueType().equals(ValueType.STRING)) {
        JsonString s = (JsonString) value;
        return s.getString();
    } else {
        return value.toString();
    }
}
 
開發者ID:ilanpillemer,項目名稱:real1ty,代碼行數:9,代碼來源:Application.java

示例11: parseAddress

import javax.json.JsonString; //導入方法依賴的package包/類
@Override
public Address parseAddress(JsonObject json) {
    JsonArray results = json.getJsonArray("results");

    if (!results.isEmpty()) {
        Address address = new Address();

        JsonObject result = (JsonObject) results.get(0);
        JsonArray components = result.getJsonArray("address_components");

        for (JsonObject component : components.getValuesAs(JsonObject.class)) {

            String value = component.getString("short_name");

            typesLoop: for (JsonString type : component.getJsonArray("types").getValuesAs(JsonString.class)) {

                switch (type.getString()) {
                    case "street_number":
                        address.setHouse(value);
                        break typesLoop;
                    case "route":
                        address.setStreet(value);
                        break typesLoop;
                    case "locality":
                        address.setSettlement(value);
                        break typesLoop;
                    case "administrative_area_level_2":
                        address.setDistrict(value);
                        break typesLoop;
                    case "administrative_area_level_1":
                        address.setState(value);
                        break typesLoop;
                    case "country":
                        address.setCountry(value);
                        break typesLoop;
                    case "postal_code":
                        address.setPostcode(value);
                        break typesLoop;
                    default:
                        break;
                }
            }
        }

        return address;
    }

    return null;
}
 
開發者ID:bamartinezd,項目名稱:traccar-service,代碼行數:50,代碼來源:GoogleGeocoder.java

示例12: decode

import javax.json.JsonString; //導入方法依賴的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.JsonString.getString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。