/** * Sets the fields excluded in serialization. These fields must be in dot notation. * This is just here so that JSONSerializer can be treated like a bean so it will * integrate with Spring or other frameworks. <strong>This is not ment to be used * in code use exclude method for that.</strong> * * @param fields the list of fields to be excluded for serialization. The fields arg should be a * list of strings in dot notation. */ public void setExcludes(List<String> fields) { for (String field : fields) { addExclude(field); } }
/** * This takes in a dot expression representing fields * to exclude when serialize method is called. You * can hand it one or more fields. Example are: "password", * "bankaccounts.number", "people.socialsecurity", or * "people.medicalHistory". In exclude method dot notations * will only exclude the final field (i.e. rightmost field). * All the fields to the left of the last field will be included. * In order to exclude the medicalHistory field we have to * include the people field since people would've been excluded * anyway since it's a Collection of Person objects. The order of * evaluation is the order in which you call the exclude method. * The first call to exclude will be evaluated before other calls to * include or exclude. The field expressions are evaluated in order * you pass to this method. * * @param fields one or more field expressions to exclude. * @return this instance for method chaining. */ public JSONSerializer exclude(String... fields) { for (String field : fields) { addExclude(field); } return this; }