Java Json Create createJsonFrom(JsonObject user, String... ignoreKeys)

Here you can find the source of createJsonFrom(JsonObject user, String... ignoreKeys)

Description

create Json From

License

Apache License

Declaration

public static JsonObjectBuilder createJsonFrom(JsonObject user,
            String... ignoreKeys) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import javax.json.Json;

import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;

import javax.json.JsonValue;

public class Main {
    public static JsonObjectBuilder createJsonFrom(JsonObject user,
            String... ignoreKeys) {
        JsonObjectBuilder builder = Json.createObjectBuilder();
        List<String> doNotCopy = Arrays.asList(ignoreKeys);

        for (Map.Entry<String, JsonValue> entry : user.entrySet()) {
            if (!!!doNotCopy.contains(entry.getKey())) {
                builder.add(entry.getKey(), entry.getValue());
            }/*w  w  w  .j a  v a  2  s . com*/
        }

        return builder;
    }
}

Related

  1. buildJsonArray(String[][] twoDimensionArray)
  2. convertToJson(Object myObject)
  3. convertToJson(Object obj)
  4. createArrayBuilder()
  5. createArrayBuilder()
  6. createJsonValue(String string)
  7. createPrettyWriterFactory()
  8. emptyArray()
  9. getJson(T t)