title: Groovy - Constructing json from String
body: <p>I'm using Groovy, i've tried to create a simple function which will construct a Json object from a provided Json string, then i'm trying to print this string but unfortunate it's adding Square brackets to the output.</p>
  
  <p>Here's a snippet from my code:</p>
  
  <pre><code>def JsonBuilder ConstructJsonObject (jsonStr) {
      def jsonToReturn = new JsonBuilder();
      def root = jsonToReturn(jsonStr);
      return jsonToReturn;
  }
  
  String jsonStr = "{id: '111'}";
  println(jsonStr);
  def jsonObject = ConstructJsonObject(jsonStr);
  println(jsonObject.toPrettyString());
  </code></pre>
  
  <p>And here's the output:</p>
  
  <p>{id: '111'}</p>
  
  <p><strong>[
      "{id: '111'}"
  ]</strong></p>
  
  <p>It's returning an Array and not a pure Json.</p>