本文整理汇总了Java中com.amazonaws.util.json.JSONObject.getJSONObject方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.getJSONObject方法的具体用法?Java JSONObject.getJSONObject怎么用?Java JSONObject.getJSONObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.util.json.JSONObject
的用法示例。
在下文中一共展示了JSONObject.getJSONObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: doPost
import com.amazonaws.util.json.JSONObject; //导入方法依赖的package包/类
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
try {
StringBuffer buffer = new StringBuffer();
String line = null;
BufferedReader reader = request.getReader();
while ((line = reader.readLine()) != null) {
buffer.append(line);
}
JSONObject jsonObject = new JSONObject(buffer.toString());
PrintWriter out = response.getWriter();
String action = jsonObject.getString("action");
log("action: " + action);
JSONObject requestObject = jsonObject.getJSONObject("request");
log("requestObject: " + requestObject);
if (action.equalsIgnoreCase("put-point")) {
putPoint(requestObject, out);
} else if (action.equalsIgnoreCase("get-point")) {
getPoint(requestObject, out);
} else if (action.equalsIgnoreCase("query-rectangle")) {
queryRectangle(requestObject, out);
} else if (action.equalsIgnoreCase("query-radius")) {
queryRadius(requestObject, out);
} else if (action.equalsIgnoreCase("delete-point")) {
deletePoint(requestObject, out);
}
} catch (Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
log(sw.toString());
}
}
示例3: fromJSON
import com.amazonaws.util.json.JSONObject; //导入方法依赖的package包/类
private AmazonCloudSearchResult fromJSON(String responseBody) throws JSONException {
AmazonCloudSearchResult result = new AmazonCloudSearchResult();
JSONObject root = new JSONObject(responseBody);
JSONObject status = root.getJSONObject("status");
if(status != null) {
result.rid = status.getString("rid");
result.time = status.getLong("time-ms");
}
JSONObject hits = root.getJSONObject("hits");
if(hits != null) {
result.found = hits.getInt("found");
result.start = hits.getInt("start");
if(result.found > 0) {
JSONArray hitArray = hits.getJSONArray("hit");
if(hitArray != null) {
for(int i = 0; i < hitArray.length(); i++) {
JSONObject row = hitArray.getJSONObject(i);
Hit hit = new Hit();
hit.id = row.getString("id");
JSONObject fields = row.getJSONObject("fields");
String[] names = JSONObject.getNames(fields);
for(String name : names) {
if(hit.fields == null) {
hit.fields = new HashMap<String, String>();
}
hit.fields.put(name, fields.getString(name));
}
if(result.hits == null) {
result.hits = new ArrayList<Hit>();
}
result.hits.add(hit);
}
}
}
}
return result;
}
示例4: doPost
import com.amazonaws.util.json.JSONObject; //导入方法依赖的package包/类
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
try {
StringBuffer buffer = new StringBuffer();
String line = null;
BufferedReader reader = request.getReader();
while ((line = reader.readLine()) != null) {
buffer.append(line);
}
JSONObject jsonObject = new JSONObject(buffer.toString());
PrintWriter out = response.getWriter();
String action = jsonObject.getString("action");
log("action: " + action);
JSONObject requestObject = jsonObject.getJSONObject("request");
log("requestObject: " + requestObject);
if (action.equalsIgnoreCase("put-point")) {
putPoint(requestObject, out);
} else if (action.equalsIgnoreCase("get-point")) {
getPoint(requestObject, out);
} else if (action.equalsIgnoreCase("update-point")) {
updatePoint(requestObject, out);
} else if (action.equalsIgnoreCase("query-rectangle")) {
queryRectangle(requestObject, out);
} else if (action.equalsIgnoreCase("query-radius")) {
queryRadius(requestObject, out);
} else if (action.equalsIgnoreCase("delete-point")) {
deletePoint(requestObject, out);
}
} catch (Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
log(sw.toString());
}
}