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

JsonSlurper with type LAX throws exception on comments in arrays

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.3.6
    • 2.3.8, 2.4.0-beta-4
    • JSON
    • None

    Description

      The LAX parser throws a groovy.json.JsonException when you put a comment after the last array element but before the closing ']'

      Example:

      import groovy.json.JsonParserType
      import groovy.json.JsonSlurper
      
      def sampleJson = '''
      [
          // good comment
          {
              "mykey" : "myvalue"
          }
          // bad comment
      ]
      '''
      def json = new JsonSlurper(type: JsonParserType.LAX).parseText(sampleJson)
      println "This should work"
      

      Expected is that this comment should also be ignored

      Attachments

        Activity

          People

            melix Cédric Champeau
            carstenlenz Carsten Lenz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: