groovy
  1. groovy
  2. GROOVY-4881

JsonSlurper does not handle backslash

    Details

    • Type: Bug Bug
    • Status: Closed 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
    • Environment:
      Gentoo Linux (amd64) / sun-jdk 1.6.0_26
    • Testcase included:
      yes
    • Number of attachments :
      1

      Description

      The JsonSlurper does not appear to handle backslash characters () even if they have been properly escaped.

      Using this sample pieced together from the Groovy 1.8.0 Release Notes:

      import groovy.json.*
      
      def json = new JsonBuilder()
      
      json.person {
          name "Guill\\aume"
          age 33
          pets "Hector", "Felix"
      }
      
      def jsonstring = json.toString()
      println jsonstring
      
      def slurper = new JsonSlurper()
      def doc = slurper.parseText(jsonstring)
      
      println doc
      

      $ groovy json.groovy

      {"person":{"name":"Guill\\aume","age":33,"pets":["Hector","Felix"]}}
      Caught: groovy.json.JsonException: Expected a value on line: 1, column: 69.
      But got an unterminated object.
              at json.run(json.groovy:15)
      

      Have tried this with 1.8.0, 1.8.1 Snapshot (2011-06-13), 1.9.0 Snapshot (2011-06-13)

      1. json.groovy
        0.3 kB
        Matt Michalowski

        Activity

        Hide
        Matt Michalowski added a comment -

        Sorry, new to both groovy & jira, have attached my code example.

        Show
        Matt Michalowski added a comment - Sorry, new to both groovy & jira, have attached my code example.

          People

          • Assignee:
            Guillaume Laforge
            Reporter:
            Matt Michalowski
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: