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

JsonSlurper with type LAX throws exception on comments in arrays

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.6
    • Fix Version/s: 2.3.8, 2.4.0-beta-4
    • Component/s: JSON
    • Labels:
      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

            • Assignee:
              melix C├ędric Champeau
              Reporter:
              carstenlenz Carsten Lenz
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: