当前位置: 首页>>代码示例>>Java>>正文


Java JSONObject.getJSONObject方法代码示例

本文整理汇总了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) {
        }
    }
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:27,代码来源:ApiGatewaySdkRamlApiImporter.java

示例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());
	}
}
 
开发者ID:aws-samples,项目名称:reinvent2013-mobile-photo-share,代码行数:38,代码来源:GeoDynamoDBServlet.java

示例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;
}
 
开发者ID:tahseen,项目名称:amazon-cloudsearch-client-java,代码行数:41,代码来源:AmazonCloudSearchClient.java

示例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());
	}
}
 
开发者ID:awslabs,项目名称:dynamodb-geo,代码行数:40,代码来源:GeoDynamoDBServlet.java


注:本文中的com.amazonaws.util.json.JSONObject.getJSONObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。