本文整理汇总了Java中com.amazonaws.util.json.JSONObject.keys方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.keys方法的具体用法?Java JSONObject.keys怎么用?Java JSONObject.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.util.json.JSONObject
的用法示例。
在下文中一共展示了JSONObject.keys方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createIntegrationResponses
import com.amazonaws.util.json.JSONObject; //导入方法依赖的package包/类
private void createIntegrationResponses(Integration integration, JSONObject responses) {
if (responses == null) {
return;
}
final Iterator<String> keysIterator = responses.keys();
while (keysIterator.hasNext()) {
String key = keysIterator.next();
try {
String pattern = key.equals("default") ? null : key;
JSONObject response = responses.getJSONObject(key);
String status = (String) response.get("statusCode");
PutIntegrationResponseInput input = new PutIntegrationResponseInput()
.withResponseParameters(jsonObjectToHashMapString(response.optJSONObject("responseParameters")))
.withResponseTemplates(jsonObjectToHashMapString(response.optJSONObject("responseTemplates")))
.withSelectionPattern(pattern);
integration.putIntegrationResponse(input, status);
} catch (JSONException e) {
}
}
}
示例2: jsonObjectToHashMapString
import com.amazonaws.util.json.JSONObject; //导入方法依赖的package包/类
private Map<String, String> jsonObjectToHashMapString (JSONObject json) {
if (json == null) {
return null;
}
final Map<String, String> map = new HashMap<>();
final Iterator<String> keysIterator = json.keys();
while (keysIterator.hasNext()) {
String key = keysIterator.next();
try {
map.put(key, json.getString(key));
} catch (JSONException e) {}
}
return map;
}
示例3: checkIfAttributesAreEqual
import com.amazonaws.util.json.JSONObject; //导入方法依赖的package包/类
/**
* Check if all the keys and the values in the request are present in the response. The response might contain additional data which is ignored.
*
* @param requestAttributes
* @param responseAttributes
* @return
* @throws Exception
*/
public static boolean checkIfAttributesAreEqual(String requestAttributes, String responseAttributes) throws Exception {
JSONObject requestJson = new JSONObject(requestAttributes);
JSONObject responseJson = new JSONObject(responseAttributes);
Iterator iterator = requestJson.keys();
while (iterator.hasNext()) {
String requestAttribute = iterator.next().toString();
if (!responseJson.has(requestAttribute) || !requestJson.get(requestAttribute).equals(responseJson.get(requestAttribute)))
return false;
}
return true;
}