groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Raviteja Lokineni (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (GROOVY-8849) Provide a way to change property names when converting Pojo to JSON
Date Wed, 17 Oct 2018 18:42:00 GMT

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

Raviteja Lokineni updated GROOVY-8849:
--------------------------------------
    Description: 
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}

  was:
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}


> 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: Major
>
> 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)

Mime
View raw message