Alternative to using the object() builder that allows you to add {@link Entry} instances.
@param fields one or more Entry instances (use the field method to create them).
@return the JsonObject with the entries added.
14600
@SafeVarargs
    public static @Nonnull JsonObject object(Entry<String,JsonElement>...fields) {
        JsonObject object = new JsonObject();
        object.add(fields);
        return object;
    }
384282
public static JsonObject jsonFromMultimap(MultiMap attributes) {
		JsonObject json = new JsonObject();
		if (attributes != null) {
			for (Map.Entry<String, String> e: attributes.entries()) {
				json.put(e.getKey(), e.getValue());
			}
		}
		return json;
	}
163516
public static Builder addToSet(String field, List<?> values) {
        return new Builder().addToSet(field, values);
    }
261026
public static @Nonnull JsonArray array(JsonBuilder... elements) {
        JsonArray jjArray = new JsonArray();
        for (JsonBuilder b : elements) {
            jjArray.add(b);
        }
        return jjArray;
    }
154403
public <P>JsonModelBuilder<T> add(JsonPropertyBuilderCreator<T> creator1,
			JsonPropertyBuilderCreator<T> creator2) {
		addSub(creator1.<P> get());
		addSub(creator2.<P> get());
		return this;
	}
1178867
public static Builder push(String field, Object value) {
        return new Builder().push(field, value);
    }
1115437
@SuppressWarnings("unchecked")
	public Q includeFields(final Set<String> fields) {
		if (this.fields == null) {
			this.fields = new HashSet<>();
		}

		if (fields != null) {
			this.fields.addAll(fields);
		}

		return (Q) this;
	}
533349
public static Object toBean( JSONObject jsonObject ) {
      if( jsonObject == null || jsonObject.isNullObject() ){
         return null;
      }

      DynaBean dynaBean = null;

      JsonConfig jsonConfig = new JsonConfig();
      Map props = JSONUtils.getProperties( jsonObject );
      dynaBean = JSONUtils.newDynaBean( jsonObject, jsonConfig );
      for( Iterator entries = jsonObject.names( jsonConfig )
            .iterator(); entries.hasNext(); ){
         String name = (String) entries.next();
         String key = JSONUtils.convertToJavaIdentifier( name, jsonConfig );
         Class type = (Class) props.get( name );
         Object value = jsonObject.get( name );
         try{
            if( !JSONUtils.isNull( value ) ){
               if( value instanceof JSONArray ){
                  dynaBean.set( key, JSONArray.toCollection( (JSONArray) value ) );
               }else if( String.class.isAssignableFrom( type )
                     || Boolean.class.isAssignableFrom( type ) || JSONUtils.isNumber( type )
                     || Character.class.isAssignableFrom( type )
                     || JSONFunction.class.isAssignableFrom( type ) ){
                  dynaBean.set( key, value );
               }else{
                  dynaBean.set( key, toBean( (JSONObject) value ) );
               }
            }else{
               if( type.isPrimitive() ){
                  // assume assigned default value
                  log.warn( "Tried to assign null value to " + key + ":" + type.getName() );
                  dynaBean.set( key, JSONUtils.getMorpherRegistry()
                        .morph( type, null ) );
               }else{
                  dynaBean.set( key, null );
               }
            }
         }catch( JSONException jsone ){
            throw jsone;
         }catch( Exception e ){
            throw new JSONException( "Error while setting property=" + name + " type" + type, e );
         }
      }

      return dynaBean;
   }
453507
static void addToObject(final JsonObjectBuilder builder, final String key, final String type, final Function<String, javax.json.JsonValue> defaultBehavior) {
        if (STRING.equals(type)) {
            builder.add(key, "string");
            return;
        }

        if (BOOLEAN.equals(type) || PRIMITIVE_BOOLEAN.equals(type)) {
            builder.add(key, false);
            return;
        }

        // TODO
//        if (INTEGER_TYPES.contains(type)) {
//            builder.add(key, 0);
//            return;
//        }
//
//        if (DOUBLE_TYPES.contains(type)) {
//            builder.add(key, 0.0);
//            return;
//        }
//
//        // plain-old date and JSR-310
//        if (type.isAssignableTo(DATE) || type.isAssignableTo(TEMPORAL_ACCESSOR)) {
//            builder.add(key, "date");
//            return;
//        }
//
//        if (type.isAssignableTo(MAP)) {
//            builder.add(key, Json.createObjectBuilder().build());
//            return;
//        }

        // fall-back
        builder.add(key, defaultBehavior.apply(type));
    }
468136
public JsonObject merge(JsonObject another) {
        for (Map.Entry<String, JsonElement> anotherEntry : another) {
            JsonElement curr = this.opt(anotherEntry.getKey());
            if (curr == null) {
                try {
                    this.put(anotherEntry.getKey(), anotherEntry.getValue());
                } catch (JsonException e) {
                    e.printStackTrace();
                }
            } else if (curr.isJsonObject() && anotherEntry.getValue().isJsonObject()) {
                curr.asJsonObject().merge(anotherEntry.getValue().asJsonObject());
            }
        }
        return this;
    }
830288
@GwtIncompatible("Class.getDeclaredFields")
	public ToStringBuilder addAllFields() {
		List<Field> fields = getAllDeclaredFields(instance.getClass());
		for(Field field : fields) {
			addField(field);
		}
		return this;
	}
136066
public static JsonObject toJsonObject(Map<String, ?> map) {
        JsonObject properties = new JsonObject();
        for (Map.Entry<String, ?> property : map.entrySet()) {
            properties.add(property.getKey(), Json.value(property.getValue().toString()));
        }
        return properties;
    }
588060
private static <T> Map<Field, TypeSerializer<?>> buildNewFieldSerializersIndex(PojoSerializer<T> newPojoSerializer) {
		final Field[] newFields = newPojoSerializer.getFields();
		final TypeSerializer<?>[] newFieldSerializers = newPojoSerializer.getFieldSerializers();

		checkState(newFields.length == newFieldSerializers.length);

		int numFields = newFields.length;
		final Map<Field, TypeSerializer<?>> index = new HashMap<>(numFields);
		for (int i = 0; i < numFields; i++) {
			index.put(newFields[i], newFieldSerializers[i]);
		}

		return index;
	}
672602
public void add(HttpFields fields)
    {
        if (fields==null)
            return;

        Enumeration enm = fields.getFieldNames();
        while( enm.hasMoreElements() )
        {
            String name = (String)enm.nextElement();
            Enumeration values = fields.getValues(name);
            while(values.hasMoreElements())
                add(name,(String)values.nextElement());
        }
    }
932490
def add_fields(self, fields):
        
        for field in fields:
            cls = field.__class__
            try:
                container = FieldsContainer.class_container[cls]
            except KeyError:
                raise ValueError('Object of type %s is an invalid field' % cls)
            getattr(self, container).append(field)
808003
public static Builder pushAll(String field, List<?> values) {
        return new Builder().pushAll(field, values);
    }
918795
@TimerJ
    public TableMetadataBuilder withClusterKey(String... fields) {
        for (String field : fields) {
            clusterKey.add(new ColumnName(tableName, field));
        }
        return this;
    }