Package com.fasterxml.jackson.core

# Enum JsonToken

java.lang.Object
java.lang.Enum<JsonToken>
com.fasterxml.jackson.core.JsonToken

All Implemented Interfaces:
  `Serializable`, `Comparable<JsonToken>`, `java.lang.constant.Constable`

public enum JsonToken extends Enum<JsonToken>
Enumeration for basic token types used for returning results of parsing JSON content.

## Nested Class Summary

## Nested classes/interfaces inherited from class java.lang.Enum

`Enum.EnumDesc<E extends Enum<E>>`

## Enum Constant Summary

Enum Constants
Enum Constant
Description
`END_ARRAY`
END_ARRAY is returned when encountering ']' which signals ending of an Array value
`END_OBJECT`
END_OBJECT is returned when encountering '}' which signals ending of an Object value
`FIELD_NAME`
FIELD_NAME is returned when a String token is encountered as a field name (same lexical value, different function)
`NOT_AVAILABLE`
NOT_AVAILABLE can be returned if `JsonParser` implementation can not currently return the requested token (usually next one), or even if any will be available, but that may be able to determine this in future.
`START_ARRAY`
START_ARRAY is returned when encountering '[' which signals starting of an Array value
`START_OBJECT`
START_OBJECT is returned when encountering '{' which signals starting of an Object value.
`VALUE_EMBEDDED_OBJECT`
Placeholder token returned when the input source has a concept of embedded Object that are not accessible as usual structure (of starting with `START_OBJECT`, having values, ending with `END_OBJECT`), but as "raw" objects.
`VALUE_FALSE`
VALUE_FALSE is returned when encountering literal "false" in value context
`VALUE_NULL`
VALUE_NULL is returned when encountering literal "null" in value context
`VALUE_NUMBER_FLOAT`
VALUE_NUMBER_FLOAT is returned when a numeric token other than integer is encountered: that is, a number that does have floating point or exponent marker in it, in addition to one or more digits (or, for non-textual formats, has internal floating-point representation).
`VALUE_NUMBER_INT`
VALUE_NUMBER_INT is returned when an integer numeric token is encountered in value context: that is, a number that does not have floating point or exponent marker in it (consists only of an optional sign, followed by one or more digits; or, for binary formats, is indicated as integral number by internal representation).
`VALUE_STRING`
VALUE_STRING is returned when a String token is encountered in value context (array element, field value, or root-level stand-alone value)
`VALUE_TRUE`
VALUE_TRUE is returned when encountering literal "true" in value context

## Method Summary

Modifier and Type
Method
Description
`final byte[]`
`asByteArray()`
`final char[]`
`asCharArray()`
`final String`
`asString()`
`final int`
`id()`
`final boolean`
`isBoolean()`
`final boolean`
`isNumeric()`
`final boolean`
`isScalarValue()`
Method that can be used to check whether this token represents a valid non-structured value.
`final boolean`
`isStructEnd()`
Accessor that is functionally equivalent to: `this == JsonToken.END_OBJECT || this == JsonToken.END_ARRAY`
`final boolean`
`isStructStart()`
Accessor that is functionally equivalent to: `this == JsonToken.START_OBJECT || this == JsonToken.START_ARRAY`
`static String`
`valueDescFor(JsonToken t)`
Helper method for constructing description like "Object value" given `JsonToken` encountered.
`static JsonToken`
`valueOf(String name)`
Returns the enum constant of this type with the specified name.
`static JsonToken[]`
`values()`
Returns an array containing the constants of this enum type, in the order they are declared.

### Methods inherited from class java.lang.Enum

`clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, wait, wait, wait`

## Enum Constant Details

### NOT_AVAILABLE

public static final JsonToken NOT_AVAILABLE
NOT_AVAILABLE can be returned if `JsonParser` implementation can not currently return the requested token (usually next one), or even if any will be available, but that may be able to determine this in future. This is the case with non-blocking parsers -- they can not block to wait for more data to parse and must return something.

### START_OBJECT

public static final JsonToken START_OBJECT
START_OBJECT is returned when encountering '{' which signals starting of an Object value.

### END_OBJECT

public static final JsonToken END_OBJECT
END_OBJECT is returned when encountering '}' which signals ending of an Object value

### START_ARRAY

public static final JsonToken START_ARRAY
START_ARRAY is returned when encountering '[' which signals starting of an Array value

### END_ARRAY

public static final JsonToken END_ARRAY
END_ARRAY is returned when encountering ']' which signals ending of an Array value

### FIELD_NAME

public static final JsonToken FIELD_NAME
FIELD_NAME is returned when a String token is encountered as a field name (same lexical value, different function)

### VALUE_EMBEDDED_OBJECT

public static final JsonToken VALUE_EMBEDDED_OBJECT
Placeholder token returned when the input source has a concept of embedded Object that are not accessible as usual structure (of starting with `START_OBJECT`, having values, ending with `END_OBJECT`), but as "raw" objects.

Note: this token is never returned by regular JSON readers, but only by readers that expose other kinds of source (like `JsonNode`-based JSON trees, Maps, Lists and such).

### VALUE_STRING

public static final JsonToken VALUE_STRING
VALUE_STRING is returned when a String token is encountered in value context (array element, field value, or root-level stand-alone value)

### VALUE_NUMBER_INT

public static final JsonToken VALUE_NUMBER_INT
VALUE_NUMBER_INT is returned when an integer numeric token is encountered in value context: that is, a number that does not have floating point or exponent marker in it (consists only of an optional sign, followed by one or more digits; or, for binary formats, is indicated as integral number by internal representation).

### VALUE_NUMBER_FLOAT

public static final JsonToken VALUE_NUMBER_FLOAT
VALUE_NUMBER_FLOAT is returned when a numeric token other than integer is encountered: that is, a number that does have floating point or exponent marker in it, in addition to one or more digits (or, for non-textual formats, has internal floating-point representation).

### VALUE_TRUE

public static final JsonToken VALUE_TRUE
VALUE_TRUE is returned when encountering literal "true" in value context

### VALUE_FALSE

public static final JsonToken VALUE_FALSE
VALUE_FALSE is returned when encountering literal "false" in value context

### VALUE_NULL

public static final JsonToken VALUE_NULL
VALUE_NULL is returned when encountering literal "null" in value context

## Method Details

### values

public static JsonToken[] values()
Returns an array containing the constants of this enum type, in the order they are declared.

Returns:
  an array containing the constants of this enum type, in the order they are declared

### valueOf

public static JsonToken valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
  `name` - the name of the enum constant to be returned.
Returns:
  the enum constant with the specified name
Throws:
  `IllegalArgumentException` - if this enum type has no constant with the specified name
  `NullPointerException` - if the argument is null

### id

public final int id()

### asString

public final String asString()

### asCharArray

public final char[] asCharArray()

### asByteArray

public final byte[] asByteArray()

### isNumeric

public final boolean isNumeric()

Returns:
  `True` if this token is `VALUE_NUMBER_INT` or `VALUE_NUMBER_FLOAT`, `false` otherwise

### isStructStart

public final boolean isStructStart()
Accessor that is functionally equivalent to: `this == JsonToken.START_OBJECT || this == JsonToken.START_ARRAY`

Returns:
  `True` if this token is `START_OBJECT` or `START_ARRAY`, `false` otherwise
Since:
  2.3

### isStructEnd

public final boolean isStructEnd()
Accessor that is functionally equivalent to: `this == JsonToken.END_OBJECT || this == JsonToken.END_ARRAY`

Returns:
  `True` if this token is `END_OBJECT` or `END_ARRAY`, `false` otherwise
Since:
  2.3

### isScalarValue

public final boolean isScalarValue()
Method that can be used to check whether this token represents a valid non-structured value. This means all `VALUE_xxx` tokens; excluding `START_xxx` and `END_xxx` tokens as well `FIELD_NAME`.

Returns:
  `True` if this token is a scalar value token (one of `VALUE_xxx` tokens), `false` otherwise

### isBoolean

public final boolean isBoolean()

Returns:
  `True` if this token is `VALUE_TRUE` or `VALUE_FALSE`, `false` otherwise

### valueDescFor

public static String valueDescFor(JsonToken t)
Helper method for constructing description like "Object value" given `JsonToken` encountered.

Parameters:
  `t` - Token to get description for
Returns:
  String description of given token
Since:
  2.16