• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JSONObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.amazonaws.util.json.JSONObject的典型用法代码示例。如果您正苦于以下问题:Java JSONObject类的具体用法?Java JSONObject怎么用?Java JSONObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JSONObject类属于com.amazonaws.util.json包,在下文中一共展示了JSONObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: delete

import com.amazonaws.util.json.JSONObject; //导入依赖的package包/类
@Override
public void delete(String url) throws IOException {

  try {
    JSONObject doc_builder = new JSONObject();

    doc_builder.put("type", "delete");

    // generate the id from the url
    String ID = CloudSearchUtils.getID(url);
    doc_builder.put("id", ID);

    // add to the batch
    addToBatch(doc_builder.toString(2), url);

  } catch (JSONException e) {
    LOG.error("Exception caught while building JSON object", e);
  }

}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:21,代码来源:CloudSearchIndexWriter.java


示例2: validateConfig

import com.amazonaws.util.json.JSONObject; //导入依赖的package包/类
private Boolean validateConfig(JSONObject config)
{
    Boolean valid = true;
    if (!config.has("accessKeyId"))
    {
        System.out.println("config parameter 'accessKeyId' is missing.");
        valid = false;
    }
    if (!config.has("secretAccessKey"))
    {
        System.out.println("config parameter 'secretAccessKey' is missing.");
        valid = false;
    }
    if (!config.has("region"))
    {
        System.out.println("config parameter 'region' is missing.");
        valid = false;
    }
    if (!config.has("tableName"))
    {
        System.out.println("config parameter 'tableName' is missing.");
        valid = false;
    }
    return valid;
}
 
开发者ID:dhorions,项目名称:DynamodbToCSV4j,代码行数:26,代码来源:d2csv.java


示例3: createApi

import com.amazonaws.util.json.JSONObject; //导入依赖的package包/类
@Override
public String createApi(Raml raml, String name, JSONObject config) {
    this.config = config;

    // TODO: What to use as description?
    final RestApi api = createApi(getApiName(raml, name), null);

    LOG.info("Created API "+api.getId());
    
    try {
        final Resource rootResource = getRootResource(api).get();
        deleteDefaultModels(api);
        createModels(api, raml.getSchemas(), false);
        createResources(api, createResourcePath(api, rootResource, raml.getBasePath()),
                         new HashMap<String, UriParameter>(), raml.getResources(), false);
    } catch (Throwable t) {
        LOG.error("Error creating API, rolling back", t);
        rollback(api);
        throw t;
    }
    return api.getId();
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:23,代码来源:ApiGatewaySdkRamlApiImporter.java


示例4: 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


示例5: 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;
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:19,代码来源:ApiGatewaySdkRamlApiImporter.java


示例6: createApi

import com.amazonaws.util.json.JSONObject; //导入依赖的package包/类
@Override
public String createApi(Raml raml, String name, JSONObject config) {
    this.config = config;

    // TODO: What to use as description?
    final RestApi api = createApi(getApiName(raml, name), null);

    LOG.info("Created API "+api.getId());
    
    try {
        final Resource rootResource = getRootResource(api).get();
        deleteDefaultModels(api);
        createModels(api, raml.getSchemas(), false);
        createResources(api, createResourcePath(api, rootResource, raml.getBasePath()), raml.getResources(), false);
    } catch (Throwable t) {
        LOG.error("Error creating API, rolling back", t);
        rollback(api);
        throw t;
    }
    return api.getId();
}
 
开发者ID:Stockflare,项目名称:aws-api-gateway,代码行数:22,代码来源:ApiGatewaySdkRamlApiImporter.java


示例7: testNotebookRun

import com.amazonaws.util.json.JSONObject; //导入依赖的package包/类
@Test
public void testNotebookRun() throws Exception
{
    String command_type = "SparkCommand";
    String language = "notebook";
    String label = "label";
    String name = "note";
    String[] tags = {"1", "2"};
    Map<String, String> arguments = new HashMap<String, String>();
    arguments.put("key", "val");
    String notebook_id = "234";
    InvokeArguments<CommandResponse> invokeargs = qdsClient.command().notebook().command_type(command_type).language(language).notebook_id(notebook_id).label(label).name(name).tags(tags).arguments(arguments).getArgumentsInvocation();
    JSONObject expectedRequestData = new JSONObject();
    expectedRequestData.put("command_type", command_type);
    expectedRequestData.put("label", label);
    expectedRequestData.put("language", language);
    expectedRequestData.put("name", name);
    expectedRequestData.put("tags", tags);
    expectedRequestData.put("arguments", arguments);
    expectedRequestData.put("note_id", notebook_id);
    assertRequestDetails(invokeargs, "POST", "commands", expectedRequestData, null, CommandResponse.class);
}
 
开发者ID:qubole,项目名称:qds-sdk-java,代码行数:23,代码来源:TestNotebook.java


示例8: verifyRecord

import com.amazonaws.util.json.JSONObject; //导入依赖的package包/类
private boolean verifyRecord(ByteBuffer buffer) throws JSONException, UnsupportedEncodingException {
	buffer.get(bytearray, 0, buffer.remaining());
	JSONObject json = new JSONObject(new String(bytearray, "UTF-8"));
	String user = json.getString("user");
	if (users.contains(user)) {
		MessageProxy proxy = MessageProxy.getInstance();
		double x = json.getDouble("latitude");
		double y = json.getDouble("longitude");
		proxy.sendMesg(user + "," + json.getDouble("latitude") + "," + json.getDouble("longitude"));
		System.out.println(x + "," + y);
		if (coordsListener.verifyCoordinates(x, y)) {
			System.out.println("Matched! '" + user + "' is at (" + x + ", " + y + ")");
			loader.put(user, System.currentTimeMillis(), x, y);
			return true;
		}
	}
	
	return false;
}
 
开发者ID:tyagihas,项目名称:awsbigdata,代码行数:20,代码来源:Processor.java


示例9: execute

import com.amazonaws.util.json.JSONObject; //导入依赖的package包/类
@Override
public void execute(Tuple input,  BasicOutputCollector collector) {
    Record record = (Record)input.getValueByField(DefaultKinesisRecordScheme.FIELD_RECORD);
    ByteBuffer buffer = record.getData();
    String data = null; 
    try {
        data = decoder.decode(buffer).toString();
        JSONObject jsonObject = new JSONObject(data);

        String referrer = jsonObject.getString("referrer");

        int firstIndex = referrer.indexOf('.');
        int nextIndex = referrer.indexOf('.',firstIndex+1);
        collector.emit(new Values(referrer.substring(firstIndex+1,nextIndex)));

    } catch (CharacterCodingException|JSONException|IllegalStateException e) {
        LOG.error("Exception when decoding record ", e);
    }
}
 
开发者ID:awslabs,项目名称:aws-big-data-blog,代码行数:20,代码来源:ParseReferrerBolt.java


示例10: queryRectangle

import com.amazonaws.util.json.JSONObject; //导入依赖的package包/类
private void queryRectangle(JSONObject requestObject, PrintWriter out) throws IOException, JSONException {
	GeoPoint minPoint = new GeoPoint(requestObject.getDouble("minLat"), requestObject.getDouble("minLng"));
	GeoPoint maxPoint = new GeoPoint(requestObject.getDouble("maxLat"), requestObject.getDouble("maxLng"));
	String filterUserId = requestObject.getString("filterUserId");

	List<String> attributesToGet = new ArrayList<String>();
	attributesToGet.add(config.getRangeKeyAttributeName());
	attributesToGet.add(config.getGeoJsonAttributeName());
	attributesToGet.add("title");
	attributesToGet.add("userId");

	QueryRectangleRequest queryRectangleRequest = new QueryRectangleRequest(minPoint, maxPoint);
	queryRectangleRequest.getQueryRequest().setAttributesToGet(attributesToGet);
	QueryRectangleResult queryRectangleResult = geoDataManager.queryRectangle(queryRectangleRequest);

	printGeoQueryResult(queryRectangleResult, out, filterUserId);
}
 
开发者ID:aws-samples,项目名称:reinvent2013-mobile-photo-share,代码行数:18,代码来源:GeoDynamoDBServlet.java


示例11: queryRadius

import com.amazonaws.util.json.JSONObject; //导入依赖的package包/类
private void queryRadius(JSONObject requestObject, PrintWriter out) throws IOException, JSONException {
	GeoPoint centerPoint = new GeoPoint(requestObject.getDouble("lat"), requestObject.getDouble("lng"));
	double radiusInMeter = requestObject.getDouble("radiusInMeter");
	String filterUserId = requestObject.getString("filterUserId");

	List<String> attributesToGet = new ArrayList<String>();
	attributesToGet.add(config.getRangeKeyAttributeName());
	attributesToGet.add(config.getGeoJsonAttributeName());
	attributesToGet.add("title");
	attributesToGet.add("userId");

	QueryRadiusRequest queryRadiusRequest = new QueryRadiusRequest(centerPoint, radiusInMeter);
	queryRadiusRequest.getQueryRequest().setAttributesToGet(attributesToGet);
	QueryRadiusResult queryRadiusResult = geoDataManager.queryRadius(queryRadiusRequest);

	printGeoQueryResult(queryRadiusResult, out, filterUserId);
}
 
开发者ID:aws-samples,项目名称:reinvent2013-mobile-photo-share,代码行数:18,代码来源:GeoDynamoDBServlet.java


示例12: assignContent

import com.amazonaws.util.json.JSONObject; //导入依赖的package包/类
private void assignContent(Request request, Object representation) {
    String contentString = new JSONObject(representation).toString();

    if (contentString == null) {
        throw new AmazonClientException("Unable to marshall representation to JSON: " + representation);
    }

    try {
        byte[] contentBytes = contentString.getBytes("UTF-8");

        request.setContent(new StringInputStream(contentString));
        request.addHeader("Content-Length", Integer.toString(contentBytes.length));
        request.addHeader("Content-Type", "application/json");
    } catch(Throwable t) {
        throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
}
 
开发者ID:awslabs,项目名称:aws-hal-client-java,代码行数:18,代码来源:HalClient.java


示例13: toJSON

import com.amazonaws.util.json.JSONObject; //导入依赖的package包/类
private JSONObject toJSON(AmazonCloudSearchAddRequest document) throws JSONException {
	JSONObject doc = new JSONObject();
	doc.put("type", "add");
	doc.put("id", document.id.toLowerCase());
	doc.put("version", document.version);
	doc.put("lang", document.lang);
	
	JSONObject fields = new JSONObject();
	for(Map.Entry<String, Object> entry : document.fields.entrySet()) {
		if(entry.getValue() instanceof Collection) {
			JSONArray array = new JSONArray();
			Iterator i = ((Collection)entry.getValue()).iterator();
			while(i.hasNext()) {
				array.put(i.next());
			}
			fields.put(entry.getKey(), array);
		} else {
			fields.put(entry.getKey(), entry.getValue());
		}
	}
	doc.put("fields", fields);
	return doc;
}
 
开发者ID:tahseen,项目名称:amazon-cloudsearch-client-java,代码行数:24,代码来源:AmazonCloudSearchClient.java


示例14: importRaml

import com.amazonaws.util.json.JSONObject; //导入依赖的package包/类
private void importRaml(String fileName, JSONObject configData, RamlApiFileImporter importer) {
    if (createNew) {
        apiId = importer.importApi(fileName, configData);

        if (cleanup) {
            importer.deleteApi(apiId);
        }
    } else {
        importer.updateApi(apiId, fileName, configData);
    }

    if (!StringUtils.isBlank(deploymentLabel)) {
        importer.deploy(apiId, deploymentLabel);
    }
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:16,代码来源:ApiImporterMain.java


示例15: importApi

import com.amazonaws.util.json.JSONObject; //导入依赖的package包/类
@Override
public String importApi(String filePath, JSONObject config) {
    LOG.info(format("Attempting to create API from RAML definition. " +
            "RAML file: %s", filePath));

    final Raml raml = parse(filePath);

    return client.createApi(raml, new File(filePath).getName(), config);
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:10,代码来源:ApiGatewayRamlFileImporter.java


示例16: updateApi

import com.amazonaws.util.json.JSONObject; //导入依赖的package包/类
@Override
public void updateApi(String apiId, String filePath, JSONObject config) {
    LOG.info(format("Attempting to update API from RAML definition. " +
            "API identifier: %s RAML file: %s", apiId, filePath));

    final Raml raml = parse(filePath);

    client.updateApi(apiId, raml, config);
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:10,代码来源:ApiGatewayRamlFileImporter.java


示例17: updateApi

import com.amazonaws.util.json.JSONObject; //导入依赖的package包/类
@Override
public void updateApi(String apiId, Raml raml, JSONObject config) {
    this.config = config;

    RestApi api = getApi(apiId);
    Optional<Resource> rootResource = getRootResource(api);

    createModels(api, raml.getSchemas(), true);
    createResources(api, createResourcePath(api, rootResource.get(), raml.getBasePath()),
                     new HashMap<String, UriParameter>(), raml.getResources(), true);

    cleanupResources(api, this.paths);
    cleanupModels(api, this.models);
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:15,代码来源:ApiGatewaySdkRamlApiImporter.java


示例18: createIntegration

import com.amazonaws.util.json.JSONObject; //导入依赖的package包/类
private void createIntegration(Resource resource, Method method, JSONObject config) {
    if (config == null) {
        return;
    }

    try {
        final JSONObject integ = config.getJSONObject(resource.getPath())
                .getJSONObject(method.getHttpMethod().toLowerCase())
                .getJSONObject("integration");

        IntegrationType type = IntegrationType.valueOf(integ.getString("type").toUpperCase());

        LOG.info("Creating integration with type " + type);

        PutIntegrationInput input = new PutIntegrationInput()
                .withType(type)
                .withUri(integ.getString("uri"))
                .withCredentials(integ.optString("credentials"))
                .withHttpMethod(integ.optString("httpMethod"))
                .withRequestParameters(jsonObjectToHashMapString(integ.optJSONObject("requestParameters")))
                .withRequestTemplates(jsonObjectToHashMapString(integ.optJSONObject("requestTemplates")))
                .withCacheNamespace(integ.optString("cacheNamespace"))
                .withCacheKeyParameters(jsonObjectToListString(integ.optJSONArray("cacheKeyParameters")));

        Integration integration = method.putIntegration(input);

        createIntegrationResponses(integration, integ.optJSONObject("responses"));
    } catch (JSONException e) {
        LOG.info(format("Skipping integration for method %s of %s: %s", method.getHttpMethod(), resource.getPath(), e));
    }
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:32,代码来源:ApiGatewaySdkRamlApiImporter.java


示例19: getAuthorizationTypeFromConfig

import com.amazonaws.util.json.JSONObject; //导入依赖的package包/类
private String getAuthorizationTypeFromConfig(Resource resource, String method, JSONObject config) {
    if (config == null) {
        return "NONE";
    }

    try {
        return config.getJSONObject(resource.getPath())
                .getJSONObject(method.toLowerCase())
                .getJSONObject("auth")
                .getString("type")
                .toUpperCase();
    } catch (JSONException exception) {
        return "NONE";
    }
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:16,代码来源:ApiGatewaySdkRamlApiImporter.java


示例20: isJSONValid

import com.amazonaws.util.json.JSONObject; //导入依赖的package包/类
public static boolean isJSONValid(String test) {
	try {
		new JSONObject(test);
	} catch (JSONException ex) {
		try {
			new JSONArray(test);
		} catch (JSONException ex1) {
			return false;
		}
	}
	return true;
}
 
开发者ID:CityOfNewYork,项目名称:CROL-WebApp,代码行数:13,代码来源:CrolService.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LZWCompressor类代码示例发布时间:2022-05-21
下一篇:
Java Value类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap