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


Java JSONObject.put方法代码示例

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


在下文中一共展示了JSONObject.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

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

示例4: getSourceInstance

import com.amazonaws.util.json.JSONObject; //导入方法依赖的package包/类
@RequestMapping(value = "/api/sourceinstance", method = RequestMethod.GET)
public ResponseEntity<String> getSourceInstance() throws JSONException {
	JSONObject resp = new JSONObject();
	resp.put("sourceInstance", instanceService.getSourceInstanceId());
	HttpHeaders headers = new HttpHeaders();
	headers.setContentType(MediaType.APPLICATION_JSON);
	return new ResponseEntity<String>(resp.toString(), headers,
			HttpStatus.OK);
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:10,代码来源:StatusController.java

示例5: createAttributes

import com.amazonaws.util.json.JSONObject; //导入方法依赖的package包/类
public static String createAttributes(Integer numAttributes) throws JSONException {
  // Create between 1 and 10 ATTRIBUTES
  int random = generator.nextInt(10) + 1;
  JSONObject jsonObject = new JSONObject();
  if (numAttributes == null)
    numAttributes = new Integer(random);
  for (int i = 0; i < numAttributes; i++) {
    jsonObject.put("key_" + i, UUID.randomUUID().toString());
  }
  return jsonObject.toString();
}
 
开发者ID:smah3sh,项目名称:mcs,代码行数:12,代码来源:DynamoRestServiceTestHelper.java

示例6: updateStringAttributes

import com.amazonaws.util.json.JSONObject; //导入方法依赖的package包/类
public static String updateStringAttributes(List<String> attributes) throws JSONException {
  JSONObject jsonObject = new JSONObject();
  for (String attribute : attributes) {
    jsonObject.put(attribute, UUID.randomUUID().toString());
  }
  return jsonObject.toString();
}
 
开发者ID:smah3sh,项目名称:mcs,代码行数:8,代码来源:DynamoRestServiceTestHelper.java

示例7: testCreateNotebook

import com.amazonaws.util.json.JSONObject; //导入方法依赖的package包/类
@Test
public void testCreateNotebook() throws Exception
{
    String name = "note1";
    String location = "Users/[email protected]";
    String note_type = "spark";
    String cluster_id = "123";
    InvokeArguments<NotebookResult> invokeargs = qdsClient.notebook().create(name, location, note_type, cluster_id).getArgumentsInvocation();
    JSONObject expectedRequestData = new JSONObject();
    expectedRequestData.put("name", name);
    expectedRequestData.put("location", location);
    expectedRequestData.put("note_type", note_type);
    expectedRequestData.put("cluster_id", cluster_id);
    assertRequestDetails(invokeargs, "POST", "notebooks", expectedRequestData, null, NotebookResult.class);
}
 
开发者ID:qubole,项目名称:qds-sdk-java,代码行数:16,代码来源:TestNotebook.java

示例8: testCloneNotebook

import com.amazonaws.util.json.JSONObject; //导入方法依赖的package包/类
@Test
public void testCloneNotebook() throws Exception
{
    String name = "note1";
    String location = "Users/[email protected]";
    String cluster_id = "123";
    String cloned_from_notebook = "234";
    InvokeArguments<NotebookResult> invokeargs = qdsClient.notebook().clone(name, location, cluster_id, cloned_from_notebook).getArgumentsInvocation();
    JSONObject expectedRequestData = new JSONObject();
    expectedRequestData.put("name", name);
    expectedRequestData.put("location", location);
    expectedRequestData.put("cluster_id", cluster_id);
    assertRequestDetails(invokeargs, "PUT", "notebooks/"+cloned_from_notebook+"/clone", expectedRequestData, null, NotebookResult.class);
}
 
开发者ID:qubole,项目名称:qds-sdk-java,代码行数:15,代码来源:TestNotebook.java

示例9: testBindNotebookToCluster

import com.amazonaws.util.json.JSONObject; //导入方法依赖的package包/类
@Test
public void testBindNotebookToCluster() throws Exception
{
    String cluster_id = "123";
    String notebook_id = "234";
    InvokeArguments<NotebookResult> invokeargs = qdsClient.notebook().bindNotebookToCluster(cluster_id, notebook_id).getArgumentsInvocation();
    JSONObject expectedRequestData = new JSONObject();
    expectedRequestData.put("cluster_id", cluster_id);
    assertRequestDetails(invokeargs, "PUT", "notebooks/"+notebook_id, expectedRequestData, null, NotebookResult.class);
}
 
开发者ID:qubole,项目名称:qds-sdk-java,代码行数:11,代码来源:TestNotebook.java

示例10: testHiveQueryCommand

import com.amazonaws.util.json.JSONObject; //导入方法依赖的package包/类
@Test
public void testHiveQueryCommand() throws Exception
{
    InvokeArguments<CommandResponse> invokeargs = qdsClient.command().hive().query("show tables;").clusterLabel("default").getArgumentsInvocation();
    JSONObject expectedRequestData=new JSONObject();
    expectedRequestData.put("command_type", "HiveCommand");
    expectedRequestData.put("label", "default");
    expectedRequestData.put("query", "show tables;");
    assertRequestDetails(invokeargs, "POST", "commands", expectedRequestData, null, CommandResponse.class);
}
 
开发者ID:qubole,项目名称:qds-sdk-java,代码行数:11,代码来源:TestCommands.java

示例11: testHiveS3Command

import com.amazonaws.util.json.JSONObject; //导入方法依赖的package包/类
@Test
public void testHiveS3Command() throws Exception
{
    InvokeArguments<CommandResponse> invokeargs = qdsClient.command().hive().scriptLocation("s3://testhive/hivecommand").clusterLabel("nondefault").getArgumentsInvocation();
    JSONObject expectedRequestData=new JSONObject();
    expectedRequestData.put("command_type", "HiveCommand");
    expectedRequestData.put("label", "nondefault");
    expectedRequestData.put("script_location", "s3://testhive/hivecommand");
    assertRequestDetails(invokeargs, "POST", "commands", expectedRequestData,  null, CommandResponse.class);
}
 
开发者ID:qubole,项目名称:qds-sdk-java,代码行数:11,代码来源:TestCommands.java

示例12: testHadoopCommandJAR

import com.amazonaws.util.json.JSONObject; //导入方法依赖的package包/类
@Test
public void testHadoopCommandJAR() throws Exception
{
    InvokeArguments<CommandResponse> invokeargs = qdsClient.command().hadoop().sub_command(HadoopCommandBuilder.SubCommandType.JAR).sub_command_args("s3n://testfiles/input.jar -mapper wc -numReduceTasks 0 -input s3n://testfiles/input -output s3://testhadoop/results").clusterLabel("default").getArgumentsInvocation();
    JSONObject expectedRequestData=new JSONObject();
    expectedRequestData.put("command_type", "HadoopCommand");
    expectedRequestData.put("label", "default");
    expectedRequestData.put("sub_command", "jar");
    expectedRequestData.put("sub_command_args", "s3n://testfiles/input.jar -mapper wc -numReduceTasks 0 -input s3n://testfiles/input -output s3://testhadoop/results");
    assertRequestDetails(invokeargs, "POST", "commands", expectedRequestData,  null, CommandResponse.class);
}
 
开发者ID:qubole,项目名称:qds-sdk-java,代码行数:12,代码来源:TestCommands.java

示例13: testHadoopCommandS3DistCP

import com.amazonaws.util.json.JSONObject; //导入方法依赖的package包/类
@Test
public void testHadoopCommandS3DistCP() throws Exception
{
    InvokeArguments<CommandResponse> invokeargs = qdsClient.command().hadoop().sub_command(HadoopCommandBuilder.SubCommandType.S3DISTCP).sub_command_args("--src s3://testhadoop/source --dest /testhadoop/destination").clusterLabel("default").getArgumentsInvocation();
    JSONObject expectedRequestData=new JSONObject();
    expectedRequestData.put("command_type", "HadoopCommand");
    expectedRequestData.put("label", "default");
    expectedRequestData.put("sub_command", "s3distcp");
    expectedRequestData.put("sub_command_args", "--src s3://testhadoop/source --dest /testhadoop/destination");
    assertRequestDetails(invokeargs, "POST", "commands", expectedRequestData, null, CommandResponse.class);
}
 
开发者ID:qubole,项目名称:qds-sdk-java,代码行数:12,代码来源:TestCommands.java

示例14: testHadoopCommandStreaming

import com.amazonaws.util.json.JSONObject; //导入方法依赖的package包/类
@Test
public void testHadoopCommandStreaming() throws Exception
{
    InvokeArguments<CommandResponse> invokeargs = qdsClient.command().hadoop().sub_command(HadoopCommandBuilder.SubCommandType.STREAMING).sub_command_args("-files s3n://testhadoop/mapper.py,s3n://testhadoop/reducer.py -mapper mapper.py -reducer reducer.py numReduceTasks 1 -input s3n://testfiles/input -output /testhadoop/results").clusterLabel("default").getArgumentsInvocation();
    JSONObject expectedRequestData=new JSONObject();
    expectedRequestData.put("command_type", "HadoopCommand");
    expectedRequestData.put("label", "default");
    expectedRequestData.put("sub_command", "streaming");
    expectedRequestData.put("sub_command_args", "-files s3n://testhadoop/mapper.py,s3n://testhadoop/reducer.py -mapper mapper.py -reducer reducer.py numReduceTasks 1 -input s3n://testfiles/input -output /testhadoop/results");
    assertRequestDetails(invokeargs, "POST", "commands", expectedRequestData, null, CommandResponse.class);
}
 
开发者ID:qubole,项目名称:qds-sdk-java,代码行数:12,代码来源:TestCommands.java

示例15: testPigCommandLatinStatement

import com.amazonaws.util.json.JSONObject; //导入方法依赖的package包/类
@Test
public void testPigCommandLatinStatement() throws Exception
{
    InvokeArguments<CommandResponse> invokeargs = qdsClient.command().pig().latin_statements("A=LOAD 's3://testpig/pig.log';dump A").clusterLabel("default").getArgumentsInvocation(); 
    JSONObject expectedRequestData=new JSONObject();
    expectedRequestData.put("command_type", "PigCommand");
    expectedRequestData.put("label", "default");
    expectedRequestData.put("latin_statements", "A=LOAD 's3://testpig/pig.log';dump A");
    assertRequestDetails(invokeargs, "POST", "commands", expectedRequestData, null, CommandResponse.class);
}
 
开发者ID:qubole,项目名称:qds-sdk-java,代码行数:11,代码来源:TestCommands.java


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