本文整理匯總了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");
}
}
示例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();
}
}
}
示例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();
}
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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();
}
示例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;
}
示例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();
}
}
示例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;
}
示例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);
}