Here you can find the source of removeElementFromJsonMap(Map
Parameter | Description |
---|---|
toscaJson | a parameter |
elementName | a parameter |
public static void removeElementFromJsonMap(Map<String, Object> toscaJson, String elementName)
//package com.java2s; /*-//from w w w . j a v a 2 s . c o m * ============LICENSE_START======================================================= * SDC * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= */ import java.util.Map; import java.util.Map.Entry; public class Main { /** * removes from Json map (toscaJson) first element found by name (elementName) note that this method could update the received argument toscaJson * * @param toscaJson * @param elementName */ public static void removeElementFromJsonMap(Map<String, Object> toscaJson, String elementName) { for (Entry<String, Object> entry : toscaJson.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (key.equals(elementName)) { toscaJson.remove(elementName); return; } else if (value instanceof Map) { removeElementFromJsonMap((Map<String, Object>) value, elementName); } } } }