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


Java JSONObject.remove方法代码示例

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


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

示例1: deleteUser

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
public void deleteUser(String username) throws EngineException {
	try {			
		synchronized (this) {
			JSONObject db = load();
			db.remove(username);
			save(db);
		}
	} catch (Exception e) {
		throw new EngineException("Failed to delete the user '" + username + "'", e);
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:12,代码来源:AuthenticatedSessionManager.java

示例2: XmlToJson

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
public static String XmlToJson(Element elt, boolean ignoreStepIds, boolean useType, JsonRoot jsonRoot) throws JSONException {
	JSONObject json = new JSONObject();
	handleElement(elt, json, ignoreStepIds, useType);
	String jsonString =   json.toString(1);
	if (jsonRoot != null && !jsonRoot.equals(JsonRoot.docNode)) {
		JSONObject jso = new JSONObject(jsonString).getJSONObject(elt.getTagName());
		if (jsonRoot.equals(JsonRoot.docChildNodes)) {
			jso.remove("attr");
		}
		jsonString = jso.toString(1);
	}
	return jsonString;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:14,代码来源:XMLUtils.java

示例3: toJson

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
private JSONObject toJson(Element element) throws JSONException {
	JSONObject jsonXml = new JSONObject();
	XMLUtils.handleElement(element, jsonXml, true, getConnector().isJsonUseType());
	if (isInputDomVariable(element)) {
		JSONObject jsonVariable = jsonXml.getJSONObject("variable");
		JSONObject jsonAttr = jsonVariable.getJSONObject("attr");
		String jsonAttrName = jsonAttr.getString("name");
		String jsonAttrValue;
		
		// Complex variable will cause exception as they have no value... 
		try {
			jsonAttrValue = jsonAttr.getString("value");
		}  catch (JSONException eValue) {
			jsonAttrValue = null;
		}

		// this is a simple variable
		if (jsonAttrValue != null) {
			JSONObject jsonobject = new JSONObject();
			jsonobject.put(jsonAttrName, jsonAttrValue);
			return jsonobject;
		}
		// this is a complex variable
		else {
			jsonVariable.remove("attr");
			return jsonVariable;
		}
	}
	return jsonXml;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:31,代码来源:AbstractCouchDbTransaction.java

示例4: invoke

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
@Override
protected JSONObject invoke() throws Exception {
	JSONObject response = super.invoke();
	if ((response.has("ok") && response.getBoolean("ok"))
		|| response.has("error") && "not_found".equals(response.getString("error"))) {
		CouchDbManager.syncDocument(getConnector());
		if (response.has("error")) {
			response.remove("error");
			response.remove("reason");
			response.put("ok", true);
		}
	}
	return response;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:15,代码来源:ResetDatabaseTransaction.java

示例5: toBeanData

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
public String toBeanData() {
	String s = jsonBean.toString();
	try {
		JSONObject jsonOb = new JSONObject(toString());
		for (Key k: Key.values()) {
			if (k.equals(Key.name))
				continue;
			if (k.equals(Key.properties)) {
				JSONObject jsonProperties = jsonOb.getJSONObject(Key.properties.name());
				if (jsonProperties != null) {
					@SuppressWarnings("unchecked")
					Iterator<String> it = jsonProperties.keys();
					while (it.hasNext()) {
						String pkey = it.next();
						if (!pkey.isEmpty()) {
							Object ob = jsonProperties.get(pkey);
							if (ob instanceof JSONObject) {
								JSONObject jsonProperty = (JSONObject)ob;
								for (IonProperty.Key kp: IonProperty.Key.values()) {
									if (kp.equals(IonProperty.Key.name)) continue;
									if (kp.equals(IonProperty.Key.mode)) continue;
									if (kp.equals(IonProperty.Key.value)) continue;
									jsonProperty.remove(kp.name());
								}
								jsonProperties.put(pkey, jsonProperty);
							}
						}
					}
					jsonOb.put(Key.properties.name(), jsonProperties);
					continue;
				}
			}
			jsonOb.remove(k.name());
		}
		s = jsonOb.toString();
	} catch (JSONException e) {
		e.printStackTrace();
	}
	//System.out.println(s);
	return s;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:42,代码来源:IonBean.java

示例6: getVariantsGA4GH

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
public List<VariantGA4GH> getVariantsGA4GH(final String callSetId, final String start, final String end,
                                           final String chrName) throws Ga4ghResourceUnavailableException {
    final ArrayList<String> listCallSetId = new ArrayList<>();
    VariantsSearch referenceBasesEntity = null;
    final List<VariantGA4GH> resultVariantSearch = new ArrayList<>();
    final JSONObject jsonObject = new JSONObject();
    final String variantSetId;
    final int index = callSetId.indexOf('-');
    if (index <= 0) {
        listCallSetId.add(callSetId + "-0");
        variantSetId = callSetId;
    } else {
        listCallSetId.add(callSetId);
        variantSetId = callSetId.substring(0, index);
    }
    try {
        jsonObject.put(Constants.CALL_SET_ID, listCallSetId);
        jsonObject.put(Constants.END_POSITION, end);
        jsonObject.put(Constants.START_POSITION, start);
        jsonObject.put(Constants.PAGE_SIZE, Constants.VARIANTS_PAGE_SIZE);
        jsonObject.put(Constants.VARIANT_SET_ID, variantSetId);
        jsonObject.put(Constants.REFERENCE_NAME, chrName);
        jsonObject.put(Constants.PAGE_TOKEN, "");
        final String location = Constants.URL_GOOGLE_GENOMIC_API +
                Constants.URL_VARIANTS +
                Constants.URL_SEARCH +
                Constants.GOOGLE_API_KEY;
        do {
            if (referenceBasesEntity != null) {
                jsonObject.remove(Constants.PAGE_TOKEN);
                jsonObject.put(Constants.PAGE_TOKEN, referenceBasesEntity.getNextPageToken());
            }
            String geneData = httpDataManager.fetchData(location, jsonObject);
            referenceBasesEntity = objectMapper.readValue(geneData, VariantsSearch.class);
            resultVariantSearch.addAll(referenceBasesEntity.getVariants());
        }
        while (!referenceBasesEntity.getNextPageToken().isEmpty());

        referenceBasesEntity.setVariants(resultVariantSearch);
    } catch (IOException | JSONException | ExternalDbUnavailableException e) {
        throw new Ga4ghResourceUnavailableException(callSetId, e);
    }

    return referenceBasesEntity.getVariants();
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:46,代码来源:VcfGa4ghReader.java


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