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

JsonOutput.toJson(object) is not returning expected results

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.8.4, 2.4.1
    • 4.0.0
    • JSON

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

        Issue Links

          Activity

            People

              emilles Eric Milles
              jsumners James Sumners
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m