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


Java JSONArray.put方法代码示例

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


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

示例1: toJSON

import com.amazonaws.util.json.JSONArray; //导入方法依赖的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

示例2: decodeParams

import com.amazonaws.util.json.JSONArray; //导入方法依赖的package包/类
private JSONObject decodeParams(String params) {
    Map<String, String[]> eparams =  Utils.decodeQueryString(params);
    JSONObject paramsObj = new JSONObject();
    for (String key : eparams.keySet()) {
        String[] vals = eparams.get(key);
        if (vals.length == 1) {
            try {
                paramsObj.put(key, Long.parseLong(vals[0]));   
            } catch (NumberFormatException e) {
                try {
                    paramsObj.put(key, Double.parseDouble(vals[0]));
                } catch (NumberFormatException e2) {
                    paramsObj.put(key, vals[0]);
                }
            }
        } else{
            JSONArray arr = new JSONArray();
            for (String s : vals) arr.put(s);
            paramsObj.put(key, arr);
        }
    }
    return paramsObj;
}
 
开发者ID:dataiku,项目名称:wt1,代码行数:24,代码来源:KafkaStorageProcessor.java

示例3: addDocuments

import com.amazonaws.util.json.JSONArray; //导入方法依赖的package包/类
/**
 * An add operation specifies either new documents that you want to add to the index or existing documents that you want to update.
 * An add operation is only applied to an existing document if the version number specified in the operation is greater than the existing document's version number.
 * 
 * @param documents The documents that need to added or updated
 * @throws JSONException 
 * @throws AwsCSMalformedRequestException 
 * @throws AwsCSInternalServerException 
 */
public void addDocuments(List<AmazonCloudSearchAddRequest> documents) throws JSONException, AmazonCloudSearchRequestException, AmazonCloudSearchInternalServerException {
	JSONArray docs = new JSONArray();
	for(AmazonCloudSearchAddRequest doc : documents) {
		docs.put(toJSON(doc));
	}
	updateDocumentRequest(docs.toString());
}
 
开发者ID:tahseen,项目名称:amazon-cloudsearch-client-java,代码行数:17,代码来源:AmazonCloudSearchClient.java

示例4: deleteDocuments

import com.amazonaws.util.json.JSONArray; //导入方法依赖的package包/类
/**
 * A delete operation specifies existing documents that you want to delete.
 * A delete operation is only applied to an existing document if the version number specified in the operation is greater than the existing document's version number.
 * 
 * @param document
 * @throws AwsCSMalformedRequestException
 * @throws AwsCSInternalServerException
 * @throws JSONException
 */
public void deleteDocuments(List<AmazonCloudSearchDeleteRequest> documents) throws JSONException, AmazonCloudSearchRequestException, AmazonCloudSearchInternalServerException {
	JSONArray docs = new JSONArray();
	for(AmazonCloudSearchDeleteRequest doc : documents) {
		docs.put(toJSON(doc));
	}
	updateDocumentRequest(docs.toString());
}
 
开发者ID:tahseen,项目名称:amazon-cloudsearch-client-java,代码行数:17,代码来源:AmazonCloudSearchClient.java

示例5: addDocument

import com.amazonaws.util.json.JSONArray; //导入方法依赖的package包/类
/**
 * An add operation specifies either a new document that you want to add to the index or an existing document that you want to update.
 * An add operation is only applied to an existing document if the version number specified in the operation is greater than the existing document's version number.
 * 
 * @param document The document that need to added or updated
 * @throws AwsCSMalformedRequestException 
 * @throws AwsCSInternalServerException 
 * @throws JSONException 
 */
public void addDocument(AmazonCloudSearchAddRequest document) throws AmazonCloudSearchRequestException, AmazonCloudSearchInternalServerException, JSONException {
	JSONArray docs = new JSONArray();
	docs.put(toJSON(document));
	updateDocumentRequest(docs.toString());
}
 
开发者ID:tahseen,项目名称:amazon-cloudsearch-client-java,代码行数:15,代码来源:AmazonCloudSearchClient.java

示例6: deleteDocument

import com.amazonaws.util.json.JSONArray; //导入方法依赖的package包/类
/**
 * A delete operation specifies an existing document that you want to delete.
 * A delete operation is only applied to an existing document if the version number specified in the operation is greater than the existing document's version number.
 * 
 * @param document
 * @throws AwsCSMalformedRequestException
 * @throws AwsCSInternalServerException
 * @throws JSONException
 */
public void deleteDocument(AmazonCloudSearchDeleteRequest document) throws AmazonCloudSearchRequestException, AmazonCloudSearchInternalServerException, JSONException {
	JSONArray docs = new JSONArray();
	docs.put(toJSON(document));
	updateDocumentRequest(docs.toString());
}
 
开发者ID:tahseen,项目名称:amazon-cloudsearch-client-java,代码行数:15,代码来源:AmazonCloudSearchClient.java


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