本文整理了Java中net.minidev.json.JSONObject.entrySet()
方法的一些代码示例,展示了JSONObject.entrySet()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.entrySet()
方法的具体详情如下:
包路径:net.minidev.json.JSONObject
类名称:JSONObject
方法名:entrySet
暂无
代码示例来源:origin: apache/tajo
private void setJdbcProperties() {
Object connPropertiesObjects = config.get(CONFIG_KEY_CONN_PROPERTIES);
if (connPropertiesObjects != null) {
Preconditions.checkState(connPropertiesObjects instanceof JSONObject, "Invalid jdbc_properties field in configs");
JSONObject connProperties = (JSONObject) connPropertiesObjects;
for (Map.Entry<String, Object> entry : connProperties.entrySet()) {
this.connProperties.put(entry.getKey(), entry.getValue());
}
}
}
代码示例来源:origin: org.apache.tajo/tajo-storage-jdbc
private void setJdbcProperties() {
Object connPropertiesObjects = config.get(CONFIG_KEY_CONN_PROPERTIES);
if (connPropertiesObjects != null) {
Preconditions.checkState(connPropertiesObjects instanceof JSONObject, "Invalid jdbc_properties field in configs");
JSONObject connProperties = (JSONObject) connPropertiesObjects;
for (Map.Entry<String, Object> entry : connProperties.entrySet()) {
this.connProperties.put(entry.getKey(), entry.getValue());
}
}
}
private Map<String, Object> getIdTokenClaims(AuthenticationContext context, String idToken) {
context.setProperty(OIDCAuthenticatorConstants.ID_TOKEN, idToken);
String base64Body = idToken.split("\\.")[1];
byte[] decoded = Base64.decodeBase64(base64Body.getBytes());
Set<Map.Entry<String, Object>> jwtAttributeSet = new HashSet<>();
try {
jwtAttributeSet = JSONObjectUtils.parseJSONObject(new String(decoded)).entrySet();
} catch (ParseException e) {
log.error("Error occurred while parsing JWT provided by federated IDP: ", e);
}
Map<String, Object> jwtAttributeMap = new HashMap();
for(Map.Entry<String, Object> entry : jwtAttributeSet) {
jwtAttributeMap.put(entry.getKey(), entry.getValue());
}
return jwtAttributeMap;
}
代码示例来源:origin: btrplace/scheduler
private static void parseVMs(Model mo, ShareableResource rc, Object o) throws JSONConverterException {
if (o != null) {
try {
JSONObject values = (JSONObject) o;
for (Map.Entry<String, Object> e : values.entrySet()) {
String k = e.getKey();
VM u = getVM(mo, Integer.parseInt(k));
int v = Integer.parseInt(e.getValue().toString());
rc.setConsumption(u, v);
}
} catch (ClassCastException cc) {
throw new JSONConverterException("Unable to read the VMs at key 'vms'. Expect a JSONObject but got a '" + o.getClass().getName() + "'", cc);
}
}
}
代码示例来源:origin: org.btrplace/scheduler-json
private static void parseVMs(Model mo, ShareableResource rc, Object o) throws JSONConverterException {
if (o != null) {
try {
JSONObject values = (JSONObject) o;
for (Map.Entry<String, Object> e : values.entrySet()) {
String k = e.getKey();
VM u = getVM(mo, Integer.parseInt(k));
int v = Integer.parseInt(e.getValue().toString());
rc.setConsumption(u, v);
}
} catch (ClassCastException cc) {
throw new JSONConverterException("Unable to read the VMs at key 'vms'. Expect a JSONObject but got a '" + o.getClass().getName() + "'", cc);
}
}
}
代码示例来源:origin: btrplace/scheduler
private static void parseNodes(Model mo, ShareableResource rc, Object o) throws JSONConverterException {
if (o != null) {
try {
JSONObject values = (JSONObject) o;
for (Map.Entry<String, Object> e : values.entrySet()) {
String k = e.getKey();
Node u = getNode(mo, Integer.parseInt(k));
int v = Integer.parseInt(e.getValue().toString());
rc.setCapacity(u, v);
}
} catch (ClassCastException cc) {
throw new JSONConverterException("Unable to read the nodes at key '" + NODES_LABEL + "'. Expect a JSONObject but got a '" + o.getClass().getName() + "'", cc);
}
}
}
}
代码示例来源:origin: btrplace/scheduler
private static void putAttributes(Attributes attrs, Element e, JSONObject entries) {
for (Map.Entry<String, Object> entry : entries.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (value.getClass().equals(Boolean.class)) {
attrs.put(e, key, (Boolean) value);
} else if (value.getClass().equals(String.class)) {
attrs.put(e, key, (String) value);
} else if (value.getClass().equals(Double.class)) {
attrs.put(e, key, (Double) value);
} else if (value.getClass().equals(Integer.class)) {
attrs.put(e, key, (Integer) value);
} else {
throw new ClassCastException(value.toString() + " is not a primitive (" + value.getClass() + ")");
}
}
}
代码示例来源:origin: org.btrplace/scheduler-json
private static void parseNodes(Model mo, ShareableResource rc, Object o) throws JSONConverterException {
if (o != null) {
try {
JSONObject values = (JSONObject) o;
for (Map.Entry<String, Object> e : values.entrySet()) {
String k = e.getKey();
Node u = getNode(mo, Integer.parseInt(k));
int v = Integer.parseInt(e.getValue().toString());
rc.setCapacity(u, v);
}
} catch (ClassCastException cc) {
throw new JSONConverterException("Unable to read the nodes at key '" + NODES_LABEL + "'. Expect a JSONObject but got a '" + o.getClass().getName() + "'", cc);
}
}
}
}
代码示例来源:origin: tomsik68/mclauncher-api
AssetIndex(String name, JSONObject json) {
this.name = name;
virtual = json.containsKey("virtual") && Boolean.parseBoolean(json.get("virtual").toString());
JSONObject objsObj = (JSONObject) json.get("objects");
for (Entry<String, Object> objectEntry : objsObj.entrySet()) {
objects.add(new Asset((JSONObject) objectEntry.getValue(), objectEntry.getKey()));
}
}
代码示例来源:origin: org.btrplace/scheduler-json
private static void putAttributes(Attributes attrs, Element e, JSONObject entries) {
for (Map.Entry<String, Object> entry : entries.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (value.getClass().equals(Boolean.class)) {
attrs.put(e, key, (Boolean) value);
} else if (value.getClass().equals(String.class)) {
attrs.put(e, key, (String) value);
} else if (value.getClass().equals(Double.class)) {
attrs.put(e, key, (Double) value);
} else if (value.getClass().equals(Integer.class)) {
attrs.put(e, key, (Integer) value);
} else {
throw new ClassCastException(value.toString() + " is not a primitive (" + value.getClass() + ")");
}
}
}
代码示例来源:origin: com.consol.citrus/citrus-core
/**
* Walks through the Json object structure and translates values based on element path if necessary.
* @param jsonData
* @param jsonPath
* @param context
*/
private void traverseJsonData(JSONObject jsonData, String jsonPath, TestContext context) {
for (Iterator it = jsonData.entrySet().iterator(); it.hasNext();) {
Map.Entry jsonEntry = (Map.Entry) it.next();
if (jsonEntry.getValue() instanceof JSONObject) {
traverseJsonData((JSONObject) jsonEntry.getValue(), (StringUtils.hasText(jsonPath) ? jsonPath + "." + jsonEntry.getKey() : jsonEntry.getKey().toString()), context);
} else if (jsonEntry.getValue() instanceof JSONArray) {
JSONArray jsonArray = (JSONArray) jsonEntry.getValue();
for (int i = 0; i < jsonArray.size(); i++) {
if (jsonArray.get(i) instanceof JSONObject) {
traverseJsonData((JSONObject) jsonArray.get(i), String.format((StringUtils.hasText(jsonPath) ? jsonPath + "." + jsonEntry.getKey() : jsonEntry.getKey().toString()) + "[%s]", i), context);
} else {
jsonArray.set(i, translate(String.format((StringUtils.hasText(jsonPath) ? jsonPath + "." + jsonEntry.getKey() : jsonEntry.getKey().toString()) + "[%s]", i), jsonArray.get(i), context));
}
}
} else {
jsonEntry.setValue(translate((StringUtils.hasText(jsonPath) ? jsonPath + "." + jsonEntry.getKey() : jsonEntry.getKey().toString()),
jsonEntry.getValue() != null ? jsonEntry.getValue() : null, context));
}
}
}
代码示例来源:origin: apache/tajo
private void loadTableSpaces(JSONObject json, boolean override) {
JSONObject spaces = (JSONObject) json.get(KEY_SPACES);
if (spaces != null) {
for (Map.Entry<String, Object> entry : spaces.entrySet()) {
JSONObject spaceDetail = (JSONObject) entry.getValue();
AddTableSpace(
entry.getKey(),
URI.create(spaceDetail.getAsString("uri")),
Boolean.parseBoolean(spaceDetail.getAsString("default")),
(JSONObject) spaceDetail.get(TABLESPACE_SPEC_CONFIGS_KEY),
override);
}
}
}
代码示例来源:origin: org.apache.tajo/tajo-storage-common
private void loadStorages(JSONObject json) {
JSONObject spaces = (JSONObject) json.get(KEY_STORAGES);
if (spaces != null) {
Pair<String, Class<? extends Tablespace>> pair = null;
for (Map.Entry<String, Object> entry : spaces.entrySet()) {
try {
pair = extractStorage(entry);
} catch (ClassNotFoundException e) {
LOG.warn(e);
continue;
}
TABLE_SPACE_HANDLERS.put(pair.getFirst(), pair.getSecond());
}
}
}
代码示例来源:origin: org.apache.tajo/tajo-storage-common
private void loadTableSpaces(JSONObject json, boolean override) {
JSONObject spaces = (JSONObject) json.get(KEY_SPACES);
if (spaces != null) {
for (Map.Entry<String, Object> entry : spaces.entrySet()) {
JSONObject spaceDetail = (JSONObject) entry.getValue();
AddTableSpace(
entry.getKey(),
URI.create(spaceDetail.getAsString("uri")),
Boolean.parseBoolean(spaceDetail.getAsString("default")),
(JSONObject) spaceDetail.get(TABLESPACE_SPEC_CONFIGS_KEY),
override);
}
}
}
代码示例来源:origin: apache/tajo
private void loadStorages(JSONObject json) {
JSONObject spaces = (JSONObject) json.get(KEY_STORAGES);
if (spaces != null) {
Pair<String, Class<? extends Tablespace>> pair = null;
for (Map.Entry<String, Object> entry : spaces.entrySet()) {
try {
pair = extractStorage(entry);
} catch (ClassNotFoundException e) {
LOG.warn(e);
continue;
}
TABLE_SPACE_HANDLERS.put(pair.getFirst(), pair.getSecond());
}
}
}
代码示例来源:origin: apache/knox
for (Entry<String, Object> entry : configProperties.entrySet()) {
configProps.put(entry.getKey(), String.valueOf(entry.getValue()));
代码示例来源:origin: btrplace/scheduler
/**
* Decorate the action with optional events.
*
* @param a the action to decorate
* @param in the JSON message containing the event at the "hook" key
* @throws JSONConverterException in case of error
*/
private void attachEvents(Action a, JSONObject in) throws JSONConverterException {
if (in.containsKey(HOOK_LABEL)) {
JSONObject hooks = (JSONObject) in.get(HOOK_LABEL);
for (Map.Entry<String, Object> e : hooks.entrySet()) {
String k = e.getKey();
try {
Action.Hook h = Action.Hook.valueOf(k.toUpperCase());
for (Object o : (JSONArray) e.getValue()) {
a.addEvent(h, eventFromJSON((JSONObject) o));
}
} catch (IllegalArgumentException ex) {
throw new JSONConverterException("Unsupported hook type '" + k + "'", ex);
}
}
}
}
代码示例来源:origin: org.btrplace/scheduler-json
/**
* Decorate the action with optional events.
*
* @param a the action to decorate
* @param in the JSON message containing the event at the "hook" key
* @throws JSONConverterException in case of error
*/
private void attachEvents(Action a, JSONObject in) throws JSONConverterException {
if (in.containsKey(HOOK_LABEL)) {
JSONObject hooks = (JSONObject) in.get(HOOK_LABEL);
for (Map.Entry<String, Object> e : hooks.entrySet()) {
String k = e.getKey();
try {
Action.Hook h = Action.Hook.valueOf(k.toUpperCase());
for (Object o : (JSONArray) e.getValue()) {
a.addEvent(h, eventFromJSON((JSONObject) o));
}
} catch (IllegalArgumentException ex) {
throw new JSONConverterException("Unsupported hook type '" + k + "'", ex);
}
}
}
}
代码示例来源:origin: btrplace/scheduler
for (Map.Entry<String, Object> e : map.entrySet()) {
String n = e.getKey();
int v = Integer.parseInt(e.getValue().toString());
代码示例来源:origin: org.btrplace/scheduler-json
for (Map.Entry<String, Object> e : map.entrySet()) {
String n = e.getKey();
int v = Integer.parseInt(e.getValue().toString());
内容来源于网络,如有侵权,请联系作者删除!