本文整理匯總了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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}