本文整理汇总了Java中javax.json.JsonValue.ValueType.STRING属性的典型用法代码示例。如果您正苦于以下问题:Java ValueType.STRING属性的具体用法?Java ValueType.STRING怎么用?Java ValueType.STRING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.json.JsonValue.ValueType
的用法示例。
在下文中一共展示了ValueType.STRING属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readAdapterNotes
private static String readAdapterNotes(JsonObject root) {
if (root.containsKey("adapterNotes")) {
JsonValue notes = root.get("adapterNotes");
if (notes.getValueType() == ValueType.STRING) {
// Return unquoted string
return ((JsonString)notes).getString();
} else {
return notes.toString();
}
}
return "";
}
示例2: jsonToMap
private Map<String, String> jsonToMap(JsonObject jsonOutput) {
Map<String, String> resultMap = new HashMap<>();
for(String key:jsonOutput.keySet()) {
JsonValue value = jsonOutput.get(key);
if(value.getValueType() == ValueType.STRING) {
resultMap.put(key, jsonOutput.getString(key));
} else if (!value.getValueType().equals(ValueType.OBJECT)&&!value.getValueType().equals(ValueType.ARRAY)) {
resultMap.put(key, jsonOutput.getString(key).toString());
}
}
return resultMap;
}
示例3: getString
/**
* Get optional long value out of the message json payload
*
* @param key
* Key to find value for
* @return value in object or null
*/
public String getString(String key) {
String result = null;
JsonObject obj = getParsedBody();
JsonValue value = obj.get(key);
if ( value != null ) {
try {
if ( value.getValueType() == ValueType.STRING) {
result = obj.getString(key);
} else {
result = value.toString();
}
} catch (Exception e) { // class cast, etc
Log.log(Level.FINER, this, "Exception parsing String: " + value, e);
// fall through to return default value
}
}
return result;
}
示例4: convertContentValue
@Override
public Object convertContentValue(Object value) {
if (value instanceof JsonValue) {
JsonValue val = (JsonValue) value;
Object ret = null;
ValueType typ = val.getValueType();
if (typ == ValueType.NUMBER)
ret = ((JsonNumber)val).bigDecimalValue();
else if (typ == ValueType.STRING)
ret = ((JsonString)val).getString();
else if (typ == ValueType.FALSE)
ret = Boolean.FALSE;
else if (typ == ValueType.TRUE)
ret = Boolean.TRUE;
else if (typ == ValueType.ARRAY) {
JsonArray arr = (JsonArray)val;
List<Object> vals = new ArrayList<Object>();
int sz = arr.size();
for (int i = 0; i < sz; i++) {
JsonValue v = arr.get(i);
vals.add(convertContentValue(v));
}
ret = vals;
} else if (typ == ValueType.OBJECT) {
//JsonObject obj = (JsonObject)val;
}
return ret;
}
return value;
}
示例5: getJsonValueAsString
private static String getJsonValueAsString(JsonValue value) {
return (value != null && value.getValueType() == ValueType.STRING) ? ((JsonString) value).getString() : null;
}
示例6: processValueFromMapOrObject
/**
* <p>
* So that the request is a valid OAuth 2.0 Authorization Request, values
* for the response_type and client_id parameters MUST be included using the
* OAuth 2.0 request syntax, since they are REQUIRED by OAuth 2.0. The
* values for these parameters MUST match those in the Request Object, if
* present.
* </p>
*
* @param reqMap
* @param key
* @param servletRequest
* @param requestObject
*/
private static void processValueFromMapOrObject(final Map<String, String> reqMap,
final String key,
final HttpServletRequest servletRequest,
final JsonObject requestObject) {
final String paramValue;
if (servletRequest != null && servletRequest.getParameter(key) != null) {
paramValue = servletRequest.getParameter(key);
} else {
paramValue = null;
}
final String requestObjectValue;
if (requestObject == null || !requestObject.containsKey(key)) {
requestObjectValue = null;
} else if (requestObject.get(key)
.getValueType() == ValueType.STRING) {
requestObjectValue = requestObject.getString(key);
} else if (requestObject.get(key)
.getValueType() == ValueType.NUMBER) {
requestObjectValue = requestObject.getJsonNumber(key)
.bigIntegerValueExact()
.toString();
} else if (requestObject.get(key)
.getValueType() == ValueType.OBJECT) {
requestObjectValue = requestObject.getJsonObject(key)
.toString();
} else {
requestObjectValue = null;
}
if (OpenIdConnectKey.CLIENT_ID.equals(key) && paramValue != null && requestObjectValue != null && !paramValue.equals(requestObjectValue)) {
throw new BadRequestException("client_id does not match.");
}
if (OpenIdConnectKey.REDIRECT_URI.equals(key) && paramValue != null && requestObjectValue != null && !paramValue.equals(requestObjectValue)) {
throw new BadRequestException("redirect_uri does not match.");
}
if (Util.isNotNullOrEmpty(requestObjectValue)) {
reqMap.put(key, requestObjectValue);
} else if (Util.isNotNullOrEmpty(paramValue)) {
reqMap.put(key, paramValue);
}
}