title: How to remove the JSON array, brackets, key and value using replaceAll method?
body: <p>I have following JSON as an output:-</p>
  
  <pre><code>def desiredJson = '{"count": 4, "max": "12", "min": 0, "details": [{"goBus": {"first": 12800, "second": 11900, "third": 12800},"goAir": {"first": 12800, "second": 11900, "third": 12800}, "gotTrain": {"first": 12800, "second": 11900},"sell": true, "darn": 2,"rate": [{ "busRate": 11900, "flag": false, "percent": 0}],}],}'
  </code></pre>
  
  <p>I want to remove "count" key and its value, remove </p>
  
  <pre><code>"goBus": {
      "first": 12800,
      "second": 11900,
      "third": 12800
  },
  </code></pre>
  
  <p>And remove square brackets of "details" node.</p>
  
  <p>I have tried below code to remove and replace as null:-</p>
  
  <pre><code>def slurper = new JsonSlurper();
  def json = slurper.parse(file)
  
  def newjson = JsonOutput.toJson(json).toString()
  
  String j = "max"
  newjson = newjson.replaceAll(""+ j +"", "")
  
  log.info newjson
  </code></pre>
  
  <p>As an output, the max value is not getting removed. Or Is there any other way we can remove these all things from JSON.</p>
  
  <p>Can anybody help me on this?</p>
  
  <p>I have tried this also:-</p>
  
  <pre><code>def json = new JsonSlurper().parseText(desiredJson)
  def njson =  json.details.goBus
  
  def pjson = njson.remove()
  
  log.info JsonOutput.toJson(pjson)
  </code></pre>
  
  <p>It is returning false.</p>