Skip to content

Commit

Permalink
Fixed #108
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 21, 2016
1 parent c12f874 commit 98f2f31
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ NOTE: Annotations module will never contain changes in patch versions,
#103: Add `JsonInclude.Include.CUSTOM`, properties for specifying filter(s) to use
#104: Add new properties in `@JsonSetter`: `merge`, `null`/`contentNulls`
#105: Add `@JsonFormat.lenient` to allow configuring lenience of date/time deserializers
#108: Allow `@JsonValue` on fields
- Allow use of `@JsonView` on classes, to specify Default View to use on non-annotated
properties.

Expand Down
26 changes: 14 additions & 12 deletions src/main/java/com/fasterxml/jackson/annotation/JsonValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
import java.lang.annotation.Target;

/**
* Marker annotation similar to
* {@link javax.xml.bind.annotation.XmlValue}
* that indicates that results of the annotated "getter" method
* (which means signature must be that of getters; non-void return
* type, no args) is to be used as the single value to serialize
* for the instance. Usually value will be of a simple scalar type
* Marker annotation
* that indicates that the value of annotated accessor (either field
* or "getter" method [a method with non-void return type, no args])
* is to be used as the single value to serialize for the instance,
* instead of the usual method of collecting properties of value.
* Usually value will be of a simple scalar type
* (String or Number), but it can be any serializable type (Collection,
* Map or Bean).
*<p>
* At most one method of a <code>Class</code> can be annotated with this annotation;
* At most one accessor of a <code>Class</code> can be annotated with this annotation;
* if more than one is found, an exception may be thrown.
* Also, if method signature is not compatible with Getters, an exception
* may be thrown (whether exception is thrown or not is an implementation detail (due
* to filtering during introspection, some annotations may be skipped)
* and applications should not rely on specific behavior).
* Also, if method signature of annotated method is not compatible with Getters,
* an exception may be thrown (whether exception is thrown or not is an
* implementation detail (due to filtering during introspection, some annotations
* may be skipped) and applications should not rely on specific behavior).
*<p>
* A typical usage is that of annotating <code>toString()</code>
* method so that returned String value is used as the JSON serialization;
Expand All @@ -39,7 +39,9 @@
*
* @see JsonCreator
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD})
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD,
ElementType.FIELD // since 2.9
})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonValue
Expand Down

0 comments on commit 98f2f31

Please sign in to comment.