Skip to content

Add annotation-based method(s) for injecting properties during serialization #638

Closed
@cowtowncoder

Description

@cowtowncoder

(note: replaces #322; possibly addresses #274)

A very common need that is not currently supported is the ability to insert additional properties in JSON (etc) output, without requiring physical POJO properties. This could include things like:

  1. Injecting Jackson attribute (2.4) values (from Add support for annotation-based integration with attributes (see #319) #322)
  2. Injecting custom BeanPropertyWriter instances (or perhaps a new sub-type), giving more control

Now; although there are some existing annotations that could work her (@JsonSerialize, specifically, from databidn package), it might make sense to add a new annotation or annotations.

Some things to consider:

  1. How to specify ordering of these attributes? While @JsonPropertyOrder needs to take these into account, it'd make sense to at least specify "default" placement before or after "regular" properties.
  2. For attributes, should name of attribute be 1-to-1 with property name to use? (fine as default, but if/how to allow override?)
  3. How to minimize amount of annotation decorations to use, without exploding number of annotations; esp. considering need to support (1) and ()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions