Groovy
  1. Groovy
  2. GROOVY-4860

Enable JsonBuilder to work with objects recursively

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.0
    • Fix Version/s: 1.8.1, 1.9-beta-1
    • Component/s: JSON
    • Labels:
      None

      Description

      Currently this code:

      def myObject = new MyObject()
      
      def json = new JsonBuilder();
      json myObject;
      println JsonOutput.prettyPrint(json.toString())
      

      Prints something like:

      [
          "MyObject@28db23f1"
      ]
      

      My suggestion:
      Introspect the object and transfer each property to json, with recursive calls for objects.

      Having looked at JsonOutput.groovy and the toJson(object) method this should be easy to implement and hugely useful!

        Activity

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development