Skip to content

Add support for annotating methods with @JsonProperty #3

@wowselim

Description

@wowselim

Right now it's not possible to annotate a function with @JsonProperty and have it be included in the json.

For example, following kotlin code will be serialized into an empty json object:

class Obj {
    val name
        get() = "John Doe"
}

If @JsonProperty would be allowed for methods, we could write the above code as follows:

class Obj {
    @get:JsonProperty("name")
    val name
        get() = "John Doe"
}

And have it be included in the serialized form. Alternatively, the serialization could include all getters by default. Jackson's ObjectMapper does the same:

class Obj {
    val name
        get() = "John Doe"
}
println(ObjectMapper().writeValueAsString(Obj()))

prints

{"name":"John Doe"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions