本文整理汇总了Java中javax.json.JsonValue.ValueType.OBJECT属性的典型用法代码示例。如果您正苦于以下问题:Java ValueType.OBJECT属性的具体用法?Java ValueType.OBJECT怎么用?Java ValueType.OBJECT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.json.JsonValue.ValueType
的用法示例。
在下文中一共展示了ValueType.OBJECT属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJsonValue
public static JsonValue getJsonValue(String json_path, JsonObject response) {
StringTokenizer tk = new StringTokenizer(json_path, "/");
JsonValue rValue = response;
JsonObject value = response;
while (tk.hasMoreTokens()) {
String key = tk.nextToken();
rValue = value.get(key);
if (rValue == null || (rValue.getValueType() != ValueType.OBJECT)) {
break;
} else {
value = (JsonObject) rValue;
}
}
return rValue;
}
示例2: getAssetMap
/**
* Return a map from id to JsonObject representing an Asset
* <p>
* This method will re-read the json file if it has not yet been read, or if it has changed since we last read it.
*/
private synchronized Map<String, JsonObject> getAssetMap() throws IOException {
if (!file.canRead()) {
throw new IOException("Cannot read repository file: " + file.getAbsolutePath());
} else if (assets == null || file.lastModified() != fileLastModified || file.length() != fileLastSize) {
// Re-read the file if either we've never read it or it's changed length since we last read it
assets = null;
fileLastModified = file.lastModified();
fileLastSize = file.length();
idCounter = new AtomicInteger(1);
assets = new HashMap<String, JsonObject>();
JsonReader reader = Json.createReader(new FileInputStream(file));
JsonArray assetList = reader.readArray();
for (JsonValue val : assetList) {
String id = Integer.toString(idCounter.getAndIncrement());
if (val.getValueType() == ValueType.OBJECT) {
assets.put(id, (JsonObject) val);
}
}
}
return assets;
}
示例3: getJsonObject
private static JsonObject getJsonObject(JsonObject object, String propName) {
JsonObject obj = null;
JsonValue val = object.get(propName);
if (val != null && val.getValueType() == ValueType.OBJECT) {
obj = val.asJsonObject();
}
return obj;
}
示例4: getObject
/**
* @param key
* @return JsonObject value or null
*/
public JsonObject getObject(String key) {
JsonObject obj = getParsedBody();
JsonValue value = obj.get(key);
if ( value != null && value.getValueType() == ValueType.OBJECT) {
return (JsonObject) value;
}
return null;
}
示例5: next
@Override
public Event next() {
if (end == null) {
end = Boolean.FALSE;
return Event.START_ARRAY;
} else if (!aentries.hasNext()) {
if (!stack.isEmpty()) {
stack.pop();
}
end = Boolean.TRUE;
return Event.END_ARRAY;
} else {
final JsonValue val = aentries.next();
final ValueType vt = val.getValueType();
if (vt == ValueType.OBJECT) {
stack.push(new ObjectIterator((JsonObject) val));
return stack.peek().next();
} else if (vt == ValueType.ARRAY) {
stack.push(new ArrayIterator((JsonArray) val));
return stack.peek().next();
} else {
currentValue = val;
return getEvent(vt);
}
}
}
示例6: 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;
}
示例7: getPathInfo
@Override
public PathInfo getPathInfo(String colKey) {
PathInfo pathInfo = null;
int colIdx = getColumnIndex(colKey);
if (colIdx == -1)
throw new RuntimeException("no result column: " + colKey);
JsonObject dataObject = (JsonObject) this.jsonValue;
JsonArray restArray = getRestArray(dataObject);
JsonValue restValue = getRestValue(restArray, colIdx);
restValue = this.handleArrayCase(restValue);
if (restValue.getValueType() == ValueType.OBJECT) {
JsonObject pathObject = (JsonObject) restValue;
String str = pathObject.getString("start");
long startId = Long.parseLong(str.substring(str.lastIndexOf('/') + 1));
str = pathObject.getString("end");
long endId = Long.parseLong(str.substring(str.lastIndexOf('/') + 1));
JsonArray rels = pathObject.getJsonArray("relationships");
List<Long> relIds = new ArrayList<Long>();
int sz = rels.size();
for (int i = 0; i < sz; i++) {
String rel = rels.getString(i);
long rid = Long.parseLong(rel.substring(rel.lastIndexOf('/') + 1));
relIds.add(Long.valueOf(rid));
}
pathInfo = new PathInfo(startId, endId, relIds, pathObject);
}
return pathInfo;
}
示例8: getJsonValueAsObject
private static JsonObject getJsonValueAsObject(JsonValue value) {
return (value != null && value.getValueType() == ValueType.OBJECT) ? value.asJsonObject() : null;
}
示例9: 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);
}
}