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] [Created] (GROOVY-8849) Provide a way to change property names when converting Pojo to JSON
Date Wed, 17 Oct 2018 18:39:00 GMT
Raviteja Lokineni created GROOVY-8849:
-----------------------------------------

             Summary: 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


I want to be able to override with something like the annotation JsonProperty to override
how a property name should be serialized to Json. 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