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


Java JsonObject.remove方法代码示例

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


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

示例1: getNextEvent

import com.google.gson.JsonObject; //导入方法依赖的package包/类
private synchronized JsonObject getNextEvent(){
	if ( events == null ){
		return null;
	}
	
	if (events.size() <= eventPtr ){
		eventPtr = 0;
	}
	
	try{
		JsonObject event = events.get(eventPtr).getAsJsonObject();
		event.remove("timestamp");
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
		sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
		event.addProperty("event_time", sdf.format(new Date()) );
		return event;
	}finally{
		eventPtr++;
	}
}
 
开发者ID:ibm-watson-data-lab,项目名称:advo-beta-producer,代码行数:21,代码来源:DataStream.java

示例2: convertMessage

import com.google.gson.JsonObject; //导入方法依赖的package包/类
private String convertMessage(String message, Map<String, String> headers) {
    String newMessage = message;
    JsonElement msgRootElement = parser.parse(message);
    if (msgRootElement instanceof JsonObject) {
        JsonObject msgRoot = (JsonObject)msgRootElement;

        JsonElement element = msgRoot.get(PAYLOAD_ELEMENT_KEY);
        if (element != null) {
            if (!element.isJsonObject()) {
                //convert payLoad to a json object if it is not already
                msgRoot.remove(PAYLOAD_ELEMENT_KEY);
                String realPayload = element.getAsString();
                String escapedPayload = StringEscapeUtils.unescapeJava(realPayload);
                msgRoot.add(PAYLOAD_ELEMENT_KEY, parser.parse(escapedPayload));
            }
        }
        JsonElement hdrElement = GSON.toJsonTree(headers);
        msgRoot.add("msgHeaders", hdrElement);
        newMessage = GSON.toJson(msgRoot);
        if (logger.isDebugEnabled()) {
            logger.debug("message to be indexed " + newMessage);
        }
    }
    return newMessage;
}
 
开发者ID:oneops,项目名称:oneops,代码行数:26,代码来源:DLQMessageProcessor.java

示例3: removeParams

import com.google.gson.JsonObject; //导入方法依赖的package包/类
/**
 * Removes all the JSON object's key-value pairs
 *
 * @param mRequest The JSON object containing the parameters for the request
 */
public static void removeParams(JsonObject mRequest) {
    mRequest.remove(TIMESTAMP);

    mRequest.remove(CARD_NUMBER);
    mRequest.remove(CARD_EXPIRY_DATE);
    mRequest.remove(CARD_CVV);

    mRequest.remove(USER_ID);
    mRequest.remove(USER_TOKEN);

    mRequest.remove(MERCHANT_AMOUNT);
    mRequest.remove(MERCHANT_ORDER);
    mRequest.remove(MERCHANT_CURRENCY);
    mRequest.remove(MERCHANT_AUTHCODE);

    mRequest.remove(PRODUCT_DESCRIPTION);
    mRequest.remove(PRODUCT_OWNER);
    mRequest.remove(PRODUCT_SCORING);

    mRequest.remove(DCC_CURRENCY);
    mRequest.remove(DCC_SESSION);

    mRequest.remove(SUBSCRIPTION_STARTDATE);
    mRequest.remove(SUBSCRIPTION_ENDDATE);
    mRequest.remove(SUBSCRIPTION_ORDER);
    mRequest.remove(SUBSCRIPTION_PERIODICITY);
    mRequest.remove(SUBSCRIPTION_AMOUNT);
    mRequest.remove(SUBSCRIPTION_CURRENCY);

    mRequest.remove(MERCHANT_SIGNATURE);
}
 
开发者ID:PayTpv,项目名称:ANDROID-SDK,代码行数:37,代码来源:AddRequestParams.java

示例4: getUpdatedFields

import com.google.gson.JsonObject; //导入方法依赖的package包/类
private JsonObject getUpdatedFields() {
    Gson gson = ServiceGenerator.getInstance().getGson();
    final Issue editedIssue;
    if (mPictureUpdated) {
        editedIssue = new Issue(mIssuename.getText().toString(),
                mIssueDesc.getText().toString(), mCategory, mRisk,
                mIssue.getLongitude(), mIssue.getLatitude(), mImageBitmap,
                mIssue.getUserAuthToken());
    } else {
        editedIssue = new Issue(mIssuename.getText().toString(),
                mIssueDesc.getText().toString(), mCategory, mRisk,
                mIssue.getLongitude(), mIssue.getLatitude(), mIssue.getPicture(),
                mIssue.getUserAuthToken());
    }

    JsonObject editedIssueParams = gson.toJsonTree(editedIssue).getAsJsonObject();

    if (mCategory == mIssue.getCategory()) {
        editedIssueParams.remove("category");
    }
    String issuename = mIssuename.getText().toString();
    if (issuename.equals(mIssue.getTitle())) {
        editedIssueParams.remove("title");
    }
    String issuedesc = mIssueDesc.getText().toString();
    if (issuedesc.equals(mIssue.getDescription())) {
        editedIssueParams.remove("description");
    }
    if (mRisk == mIssue.isRisk()) {
        editedIssueParams.remove("risk");
    }
    if (!mPictureUpdated) {
        editedIssueParams.remove("picture");
    }
    return editedIssueParams;
}
 
开发者ID:ArnauBlanch,项目名称:civify-app,代码行数:37,代码来源:EditIssueActivity.java

示例5: addAlarmLogMap

import com.google.gson.JsonObject; //导入方法依赖的package包/类
public void addAlarmLogMap(int type, String str, Long timestamp) {
    if (str == null) {
        return;
    }
    JsonParser jsonToken = new JsonParser();
    JsonObject objToken = jsonToken.parse(str).getAsJsonObject();
    String filePath = objToken.get("filepath").getAsString();
    Integer line = objToken.get("fileline").getAsInt();
    objToken.remove("mytraceid");
    objToken.remove("myrpcid");
    objToken.remove("filepath");
    objToken.remove("fileline");
    String tokenStr = objToken.toString();
    String token = getToken(tokenStr);
    SimHash hash1;
    try {
        hash1 = new SimHash(token, 64);
        //hash1.subByDistance(hash1,3);
    } catch (Exception e) {
        log.debug(e.getMessage());
        return;
    }
    switch (type) {
        case 5:
            addLogInfo(_errorLogMap, str, token, timestamp, filePath, line, hash1, 5);
            break;
        case 6:
            addLogInfo(_alarmLogMap, str, token, timestamp, filePath, line, hash1, 6);
            break;
        case 7:
            addLogInfo(_exceptionLogMap, str, token, timestamp, filePath, line, hash1, 7);
            break;
    }
}
 
开发者ID:weiboad,项目名称:fiery,代码行数:35,代码来源:ErrorStatistic.java

示例6: hash

import com.google.gson.JsonObject; //导入方法依赖的package包/类
private JsonObject hash(JsonObject base) {
    base.remove(EventKey.Hashes.get());
    base.remove(EventKey.Signatures.get());
    JsonElement unsigned = base.remove(EventKey.Unsigned.get());
    String canonical = MatrixJson.encodeCanonical(base);

    JsonObject hashes = new JsonObject();
    hashes.addProperty("sha256", sha256.hash(canonical)); // FIXME do not hardcode
    base.add(EventKey.Hashes.get(), hashes);
    base.add(EventKey.Unsigned.get(), unsigned);
    return base;
}
 
开发者ID:kamax-io,项目名称:mxhsd,代码行数:13,代码来源:EventManager.java

示例7: deserialize

import com.google.gson.JsonObject; //导入方法依赖的package包/类
@Override
public Document deserialize(JsonElement json, Type typeOfT,
                            JsonDeserializationContext context) {

    JsonObject obj = json.getAsJsonObject();
    JsonElement currentLayerEl = obj.remove(CURRENT_LAYER);

    Document document = g.fromJson(obj, Document.class);
    LayerGroup root = document.getRoot();

    if (root != null && currentLayerEl != null) {
        Layer currentLayer = null;
        if (currentLayerEl.isJsonArray()) {
            JsonArray jsonIds = currentLayerEl.getAsJsonArray();

            SelectionGroup selection = new SelectionGroup();
            for (JsonElement el : jsonIds) {
                UUID id = UUID.fromString(el.getAsString());
                Layer l = root.findLayerById(id);
                if (l != null) {
                    selection.addLayer(l);
                }
            }
            currentLayer = selection;
        } else {
            UUID currentLayerId = UUID.fromString(currentLayerEl.getAsString());
            currentLayer = root.findLayerById(currentLayerId);
        }

        document.setCurrentLayer(currentLayer);
    }
    return document;
}
 
开发者ID:google,项目名称:spline,代码行数:34,代码来源:DocumentRepository.java

示例8: addNode

import com.google.gson.JsonObject; //导入方法依赖的package包/类
public synchronized void addNode(String node, String value) {
	try {
		JsonObject jsonObject = new Gson().fromJson(getConfigFileContents(), JsonObject.class);
		if (jsonObject.has(node)) {
			jsonObject.remove(node);
		}
		jsonObject.add(node, new JsonPrimitive(value));
		flushConfig(jsonObject.toString());
	} catch (Exception ex) {
		;
	}
}
 
开发者ID:Moudoux,项目名称:EMC,代码行数:13,代码来源:Settings.java

示例9: deleteNode

import com.google.gson.JsonObject; //导入方法依赖的package包/类
public synchronized void deleteNode(String node) {
	try {
		JsonObject jsonObject = new Gson().fromJson(getConfigFileContents(), JsonObject.class);
		if (jsonObject.has(node)) {
			jsonObject.remove(node);
		}
		flushConfig(jsonObject.toString());
	} catch (Exception ex) {
		;
	}
}
 
开发者ID:Moudoux,项目名称:EMC,代码行数:12,代码来源:Settings.java

示例10: filterGroups

import com.google.gson.JsonObject; //导入方法依赖的package包/类
public byte[] filterGroups(HttpServletRequest request, byte[] content) {
	byte[] newContent = content;
	if (ArrayUtils.isEmpty(newContent)) {
		return newContent;
	}
	try {
		String method = request.getMethod();
		String uri = request.getRequestURI();
		String queryString = request.getQueryString();
		String path = uri + "?" + queryString;
		String url = AuthUtil.QUERY_GROUP_URI;
		if (AuthUtil.HTTP_GET.equalsIgnoreCase(method) && path.equalsIgnoreCase(url)) {
			String umContent = MessageGZIP.uncompressToString(newContent);
			

			User user = AuthUtil.THREAD_LOCAL_USER.get();
			if (user == null) {
				log.warn("AuthUtil.THREAD_LOCAL_USER.get()");
				return null;
			}

			JsonObject jsonObject = new JsonParser().parse(umContent)
					.getAsJsonObject();

			// 新的jsonArrayGroups
			JsonArray newJsonArrayGroups = new JsonArray();

			JsonArray jsonArrayGroups = jsonObject.getAsJsonArray("groups");
			
			log.info("jsonArrayGroups.size >>>>>{}", jsonArrayGroups.size());

			if (!jsonArrayGroups.isJsonNull()) {
				for (JsonElement jsonElement : jsonArrayGroups) {
					JsonObject jsonObjectGroup = jsonElement
							.getAsJsonObject();
					String id = jsonObjectGroup.get("id").getAsString();
					Permission permission = AuthUtil
							.getQueryPermission(user);
					log.info(" path >>>>>>  {} permission >>>> {}", id,permission);
					if (permission != null) {
						String queryPath = permission.getOn();
						// 判断分组查询权限
						if ("/".equals(queryPath) || queryPath.contains(id)) {
							newJsonArrayGroups.add(jsonElement);
						}
					}
				}
			}

			jsonObject.remove("groups");
			jsonObject.add("groups", newJsonArrayGroups);

			String newContentStr = jsonObject.toString();

			newContent = MessageGZIP.compressToByte(newContentStr);

			log.info("newJsonArrayGroups.size >>>>>{}", newJsonArrayGroups.size());

		}
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}

	return newContent;
}
 
开发者ID:xiaomin0322,项目名称:marathon-auth-plugin,代码行数:66,代码来源:HTTPAuthFilter.java

示例11: testUserWithNullFieldsFromJson

import com.google.gson.JsonObject; //导入方法依赖的package包/类
@Test
public void testUserWithNullFieldsFromJson() {

    JsonObject obj = getExampleValidUser();
    obj.remove(FacebookUser.kNAME);

    FacebookUser usr = new FacebookUser(obj);
    assertTrue(usr.getId().equals(testUid));
    assertTrue(usr.getName() == null);
    assertTrue(usr.getPicture().equals(testPicture));
}
 
开发者ID:simoneapp,项目名称:S3-16-simone,代码行数:12,代码来源:FacebookUserTest.java

示例12: parseNode

import com.google.gson.JsonObject; //导入方法依赖的package包/类
/**
 * Method for parsing a node from the dump file.
 *
 * @param s Node to parse and convert.
 */
private void parseNode(String s) {
    // initialSplit[0] contains id and node label
    // initialSplit[1] contains properties of the node
    String[] initialSplit = s.split("` ");

    String[] idAndLabel = initialSplit[0].split(":`");
    int id = Integer.parseInt(idAndLabel[0].substring(2));

    // recover the name of the label.
    for (int i = 2; i < idAndLabel.length; i++) {
        idAndLabel[1] += idAndLabel[i];
    }

    // obtain the label of the node. In the case of multiple labels, the label in the schema
    // becomes a comma separated value of the multiple labels.
    String nodeLabel = idAndLabel[1].replace("`", ", ");

    // obtain the properties of the node (format = JSON object).
    String props = initialSplit[1].replace("`", "");
    JsonObject o = (JsonObject) SchemaConvert.parser.parse(props.substring(0, props.length() - 1));

    // For each possible key that *may* contain a list...
    for (String l : propsX.getListFields()) {
        if (o.has(l) && !o.get(l).isJsonArray()) {
            String list_val = o.get(l).getAsString();
            JsonArray j_array = new JsonArray();
            j_array.add(list_val);
            o.remove(l);
            o.add(l, j_array);
        }
    }

    o.addProperty("id", id);
    o.addProperty("label", nodeLabel);

    for (Map.Entry<String, JsonElement> entry : o.entrySet()) {
        // calculate the datatype of the value
        String type = calculateDataType(entry.getKey(), entry.getValue());
        addToLabelMap(nodeLabel, entry.getKey(), type);

        if (!SchemaConvert.nodeRelLabels.contains(entry.getKey() + " TEXT") &&
                !SchemaConvert.nodeRelLabels.contains(entry.getKey() + " INT") &&
                !SchemaConvert.nodeRelLabels.contains(entry.getKey() + " REAL") &&
                !SchemaConvert.nodeRelLabels.contains(entry.getKey() + " BOOLEAN") &&
                !SchemaConvert.nodeRelLabels.contains(entry.getKey() + " BIGINT") &&
                !SchemaConvert.nodeRelLabels.contains(entry.getKey() + " TEXT[]")) {
            SchemaConvert.nodeRelLabels.add(entry.getKey() + " " + type);
        }
    }

    try {
        bwNodes.write(o.toString());
        bwNodes.newLine();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:DTG-FRESCO,项目名称:cyp2sql,代码行数:63,代码来源:PerformWork.java

示例13: inkValueToSvg

import com.google.gson.JsonObject; //导入方法依赖的package包/类
public static Document inkValueToSvg(byte[]... inkValues) throws Exception {
	if (inkValues != null && inkValues.length > 0) {
		DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
		String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
		Document doc = impl.createDocument(svgNS, "svg", null);
		// Get the root element (the 'svg' element).
		Element svgRoot = doc.getDocumentElement();
		// Set the width and height attributes on the root 'svg' element.
		// svgRoot.setAttributeNS(null, "width", "400");
		// svgRoot.setAttributeNS(null, "height", "450");
		for (int i = 0; i < inkValues.length; i++) {
			String inkJson = inkValueToString(inkValues[i]);
			if (inkJson != null) {
				JsonElement strokes = new JsonParser().parse(inkJson);
				Iterator<JsonElement> strokesIt = strokes.getAsJsonArray().iterator();
				while (strokesIt.hasNext()) {
					JsonObject stroke = strokesIt.next().getAsJsonObject();
					// Create the rectangle.
					Element path = doc.createElementNS(svgNS, "path");
					StringBuilder d = new StringBuilder();
					getSvgPath(stroke.get("path"), d);
					if (d.length() > 0) {
						path.setAttributeNS(null, "d", d.toString());
						stroke.remove("path");
						Iterator<Entry<String, JsonElement>> strokeAttributesIt = stroke.entrySet().iterator();
						while (strokeAttributesIt.hasNext()) {
							Entry<String, JsonElement> strokeAttribute = strokeAttributesIt.next();
							// StringBuilder attributeValue = new StringBuilder();
							// if (strokeAttribute.getValue().isJsonArray()) {
							// Iterator<JsonElement> it = strokeAttribute.getValue().getAsJsonArray().iterator();
							// while (it.hasNext()) {
							// attributeValue.append(it.next().getAsString());
							// }
							// } else {
							// attributeValue.append(strokeAttribute.getValue().getAsString());
							// }
							if (strokeAttribute.getValue().isJsonPrimitive()) {
								path.setAttributeNS(null, strokeAttribute.getKey(), strokeAttribute.getValue().getAsString());
							}
						}
						// rectangle.setAttributeNS(null, "y", "20");
						// rectangle.setAttributeNS(null, "width", "100");
						// rectangle.setAttributeNS(null, "height", "50");
						// rectangle.setAttributeNS(null, "fill", "red");
						// Attach the rectangle to the root 'svg' element.
						svgRoot.appendChild(path);
					}
				}
			}

		}
		return doc;
	}
	return null;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:56,代码来源:CommonUtil.java


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