You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2018/11/19 22:38:00 UTC

[jira] [Closed] (GROOVY-8849) Provide a way to change property names when converting Pojo to JSON

     [ https://issues.apache.org/jira/browse/GROOVY-8849?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King closed GROOVY-8849.
-----------------------------

> Provide a way to change property names when converting Pojo to JSON
> -------------------------------------------------------------------
>
>                 Key: GROOVY-8849
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8849
>             Project: Groovy
>          Issue Type: New Feature
>          Components: JSON
>    Affects Versions: 2.5.0
>            Reporter: Raviteja Lokineni
>            Priority: Minor
>
> I want to be able to override with something like the annotation JsonProperty to override how a property name should be serialized to Json. If the feature is already there then please add documentation. For example:
> {code:java}
> @JsonProperty("test_one")
> int testOne
> @JsonProperty("test_two")
> int testTwo{code}
> More information on the example: [Jackson-Annotations|https://github.com/FasterXML/jackson-annotations/wiki/Jackson-Annotations] 
> h1. Reproducible Code
> h2. Pojo.groovy
> {code:java}
> class Pojo {
>   int testOne
>   int testTwo
> }{code}
> h2. Sample Run:
> {code:java}
> JsonOutput.toJson(new Pojo(testOne: 1, testTwo: 1))
> // Output
> // ===> {"testTwo":1,"testOne":1}
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)