Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-5169

JsonOutput.toJson(object) is not returning expected results

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.8.4, 2.4.1
    • Fix Version/s: None
    • Component/s: JSON
    • Labels:

      Description

      Consider the attached Groovy script. It defines two classes. Each has public properties explicitly defined. When I send the resulting objects to JsonOutput.toJson(), I expect the public properties of the object to be serialized into the JSON output. This is not working as expected. The only properties that get serialized are those created via "def propName" and those that seem to have getter methods (this in not actually the case).

      Attached is a screenshot of GroovyConsole running the attached script.

        Attachments

        1. 0001-bugfix.patch
          2 kB
          Umang Bhatt
        2. 0002_patch.txt
          2 kB
          Umang Bhatt
        3. GroovyConsole_output.png
          275 kB
          James Sumners
        4. json_test.groovy
          0.8 kB
          James Sumners
        5. MetaClassImpl.java
          151 kB
          Umang Bhatt
        6. MetaClassImpl.patch
          2 kB
          Jochen Theodorou
        7. screenshot.png
          67 kB
          Umang Bhatt

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jsumners James Sumners
            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated: