Package: groovy.json

## [Java] Enum JsonTokenType

- groovy.json.JsonTokenType

-     public enum JsonTokenType

  The original slurper and lexer use this class. This is kept around in case someone needs its exact behavior. Enum listing all the possible JSON tokens that should be recognized by the lexer.

  Since:
    1.8.0

- - ### Enum Constants Summary

    Enum constants classes
    Enum constant | Description
    --- | ---
    `CLOSE_BRACKET` | Closing square bracket token.
    `CLOSE_CURLY` | Closing curly brace token.
    `COLON` | Colon token.
    `COMMA` | Comma token.
    `FALSE` | `false` literal token.
    `NULL` | `null` literal token.
    `NUMBER` | Numeric literal token.
    `OPEN_BRACKET` | Opening square bracket token.
    `OPEN_CURLY` | Opening curly brace token.
    `STRING` | String literal token.
    `TRUE` | `true` literal token.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public String` | `getLabel()` Returns the human-readable description of this token type.
    `` | `public Object` | `getValidator()` Returns the validator used to recognize this token type.
    `` | `public boolean` | `matching(String input)` Tells if an input string matches a token.
    `` | `public static JsonTokenType` | `startingWith(char c)` Find which JSON value might be starting with a given character

  - ### Inherited Methods Summary

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

- - ### Enum Constant Detail

    - #### JsonTokenType CLOSE_BRACKET

      Closing square bracket token.

    - #### JsonTokenType CLOSE_CURLY

      Closing curly brace token.

    - #### JsonTokenType COLON

      Colon token.

    - #### JsonTokenType COMMA

      Comma token.

    - #### JsonTokenType FALSE

      `false` literal token.

    - #### JsonTokenType NULL

      `null` literal token.

    - #### JsonTokenType NUMBER

      Numeric literal token.

    - #### JsonTokenType OPEN_BRACKET

      Opening square bracket token.

    - #### JsonTokenType OPEN_CURLY

      Opening curly brace token.

    - #### JsonTokenType STRING

      String literal token.

      Original pattern throws the StackOverflowError for long strings with backslashes. It is therefore replaced by a 2-step approach inspired by json2.js sources: https://github.com/douglascrockford/JSON-js/blob/master/json2.js#L462 See JsonTokenTypeTest#testMatchingLongStringWithBackslashes() for details.

    - #### JsonTokenType TRUE

      `true` literal token.

  - ### Method Detail

    - #### public String getLabel()

      Returns the human-readable description of this token type.

      Returns:
        the token label

    - #### public Object getValidator()

      Returns the validator used to recognize this token type.

      Returns:
        the token validator

    - #### public boolean matching(String input)

      Tells if an input string matches a token.

      Parameters:
        `input` - the input string to match
      Returns:
        a `Matching` enum value: `YES` if this is an exact match, `POSSIBLE` if more characters could turn the input string into a valid token, or `NO` if the string cannot possibly match the pattern even with more characters to read.

    - #### public static JsonTokenType startingWith(char c)

      Find which JSON value might be starting with a given character

      Parameters:
        `c` - the character
      Returns:
        the possible token type found