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

JsonOutput.toJson(object) does not handle char[] correctly

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8.0, 1.8.1
    • Fix Version/s: 1.8.2, 1.9-beta-3
    • Component/s: groovy-jdk
    • Labels:
      None

      Description

      Currently

      println new JsonBuilder(['a','b','c','d'] as char[]).toString()

      will output

      [{},{},{},{}]

      since the primitive class char has no properties (other than class).

      My solution is to call toString on the object if there are no properties left. I have attached an updated JsonOutput.groovy and a fixed test.

        Attachments

        1. GROOVY-4984.patch
          1 kB
          Seth Miller
        2. JsonOutput.groovy
          6 kB
          Seth Miller
        3. JsonOutputTest.groovy
          9 kB
          Seth Miller

          Activity

            People

            • Assignee:
              Guillaume Guillaume Delcroix
              Reporter:
              seth.miller Seth Miller
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: