Package: groovy.json

## [Java] Class JsonSlurperClassic

- groovy.json.JsonSlurperClassic

-     public class JsonSlurperClassic
      extends Object

  This is the original slurper included in case someone relies on its exact behavior. JSON slurper which parses text or reader content into a data structure of lists and maps.

  Example usage: ``

       def slurper = new groovy.json.JsonSlurperClassic()
       def result = slurper.parseText('{"person":{"name":"Guillaume","age":33,"pets":["dog","cat"]}}')

       assert result.person.name == "Guillaume"
       assert result.person.age == 33
       assert result.person.pets.size() == 2
       assert result.person.pets[0] == "dog"
       assert result.person.pets[1] == "cat"

  Since:
    1.8.0

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public int` | `getMaxNestingDepth()` Returns the maximum nesting depth of arrays/objects the parser will accept.
    `` | `public int` | `getMaxNumberLength()` Returns the maximum length permitted for a single number token.
    `` | `public Object` | `parse(Reader reader)` Parse a JSON data structure from content from a reader
    `` | `public Object` | `parse(File file)` Parse a JSON data structure from content within a given File.
    `` | `public Object` | `parse(File file, String charset)` Parse a JSON data structure from content within a given File.
    `` | `public Object` | `parse(URL url)` Parse a JSON data structure from content at a given URL.
    `` | `public Object` | `parse(URL url, Map params)` Parse a JSON data structure from content at a given URL.
    `` | `public Object` | `parse(Map params, URL url)` Parse a JSON data structure from content at a given URL.
    `` | `public Object` | `parse(URL url, String charset)` Parse a JSON data structure from content at a given URL.
    `` | `public Object` | `parse(URL url, Map params, String charset)` Parse a JSON data structure from content at a given URL.
    `` | `public Object` | `parse(Map params, URL url, String charset)` Parse a JSON data structure from content at a given URL.
    `` | `public Object` | `parseText(String text)` Parse a text representation of a JSON data structure
    `` | `public void` | `setMaxNestingDepth(int maxNestingDepth)` Sets the maximum nesting depth of arrays/objects the parser will accept before throwing a JsonException.
    `` | `public void` | `setMaxNumberLength(int maxNumberLength)` Sets the maximum length, in characters, of a single number token the parser will accept before throwing a JsonException.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### public int getMaxNestingDepth()

      Returns the maximum nesting depth of arrays/objects the parser will accept.

      Returns:
        the maximum nesting depth, or a value `<= 0` when the check is disabled
      Since:
        6.0.0

    - #### public int getMaxNumberLength()

      Returns the maximum length permitted for a single number token.

      Returns:
        the maximum number token length, or a value `<= 0` when the check is disabled
      Since:
        6.0.0

    - #### public Object parse(Reader reader)

      Parse a JSON data structure from content from a reader

      Parameters:
        `reader` - reader over a JSON content
      Returns:
        a data structure of lists and maps

    - #### public Object parse(File file)

      Parse a JSON data structure from content within a given File.

      Parameters:
        `file` - File containing JSON content
      Returns:
        a data structure of lists and maps
      Since:
        2.2.0

    - #### public Object parse(File file, String charset)

      Parse a JSON data structure from content within a given File.

      Parameters:
        `file` - File containing JSON content
        `charset` - the charset for this File
      Returns:
        a data structure of lists and maps
      Since:
        2.2.0

    - #### public Object parse(URL url)

      Parse a JSON data structure from content at a given URL.

      Parameters:
        `url` - URL containing JSON content
      Returns:
        a data structure of lists and maps
      Since:
        2.2.0

    - #### public Object parse(URL url, Map params)

      Parse a JSON data structure from content at a given URL.

      Parameters:
        `url` - URL containing JSON content
        `params` - connection parameters
      Returns:
        a data structure of lists and maps
      Since:
        2.2.0

    - #### public Object parse(Map params, URL url)

      Parse a JSON data structure from content at a given URL. Convenience variant when using Groovy named parameters for the connection params.

      Parameters:
        `params` - connection parameters
        `url` - URL containing JSON content
      Returns:
        a data structure of lists and maps
      Since:
        2.2.0

    - #### public Object parse(URL url, String charset)

      Parse a JSON data structure from content at a given URL.

      Parameters:
        `url` - URL containing JSON content
        `charset` - the charset for this File
      Returns:
        a data structure of lists and maps
      Since:
        2.2.0

    - #### public Object parse(URL url, Map params, String charset)

      Parse a JSON data structure from content at a given URL.

      Parameters:
        `url` - URL containing JSON content
        `params` - connection parameters
        `charset` - the charset for this File
      Returns:
        a data structure of lists and maps
      Since:
        2.2.0

    - #### public Object parse(Map params, URL url, String charset)

      Parse a JSON data structure from content at a given URL. Convenience variant when using Groovy named parameters for the connection params.

      Parameters:
        `params` - connection parameters
        `url` - URL containing JSON content
        `charset` - the charset for this File
      Returns:
        a data structure of lists and maps
      Since:
        2.2.0

    - #### public Object parseText(String text)

      Parse a text representation of a JSON data structure

      Parameters:
        `text` - JSON text to parse
      Returns:
        a data structure of lists and maps

    - #### public void setMaxNestingDepth(int maxNestingDepth)

      Sets the maximum nesting depth of arrays/objects the parser will accept before throwing a JsonException. A value of `0` or less disables the check.

      Parameters:
        `maxNestingDepth` - maximum number of nested arrays/objects to allow
      Since:
        6.0.0

    - #### public void setMaxNumberLength(int maxNumberLength)

      Sets the maximum length, in characters, of a single number token the parser will accept before throwing a JsonException. A value of `0` or less disables the check.

      Parameters:
        `maxNumberLength` - maximum number of characters in a number token
      Since:
        6.0.0