Here you can find the source of union(JsonObject... values)
Parameter | Description |
---|---|
values | an array of Json objects. |
public static JsonObject union(JsonObject... values)
//package com.java2s; /******************************************************************************* * Copyright 2015, 2016 Junichi Tatemura * * 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.//from ww w .j a v a 2s .co m *******************************************************************************/ import java.util.Map; import javax.json.Json; import javax.json.JsonObject; import javax.json.JsonObjectBuilder; import javax.json.JsonValue; public class Main { /** * Merges (unions) a list of Json objects into one object. * @param values an array of Json objects. * @return the merged object. */ public static JsonObject union(JsonObject... values) { JsonObjectBuilder builder = Json.createObjectBuilder(); for (JsonObject v : values) { for (Map.Entry<String, JsonValue> e : v.entrySet()) { builder.add(e.getKey(), e.getValue()); } } return builder.build(); } }