Groovy
  1. Groovy
  2. GROOVY-4984

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

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor 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.

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

        Activity

        Seth Miller created issue -
        Guillaume Delcroix made changes -
        Field Original Value New Value
        Assignee Guillaume Laforge [ guillaume ]
        Seth Miller made changes -
        Attachment GROOVY-4984.patch [ 56611 ]
        Guillaume Delcroix made changes -
        Fix Version/s 1.8.2 [ 17495 ]
        Fix Version/s 1.9-beta-2 [ 17494 ]
        Guillaume Delcroix made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12733910 ] Default workflow, editable Closed status [ 12745725 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12971451 ] Default workflow, editable Closed status [ 12979257 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development