Top Description Fields Constructors Methods
com.fasterxml.jackson.core

public final Enum JsonToken

extends Enum<JsonToken>
Class Inheritance

Enumeration for basic token types used for returning results of parsing JSON content.

Field Summary

Modifier and TypeField and Description
pack-priv final int
pack-priv final boolean
pack-priv final boolean
pack-priv final boolean
pack-priv final boolean
pack-priv final boolean
pack-priv final String
pack-priv final byte[]
pack-priv final char[]
public static final JsonToken
END_ARRAY

END_ARRAY is returned when encountering ']' which signals ending of an Array value

public static final JsonToken
END_OBJECT

END_OBJECT is returned when encountering '}' which signals ending of an Object value

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)

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.

public static final JsonToken
START_ARRAY

START_ARRAY is returned when encountering '[' which signals starting of an Array value

public static final JsonToken
START_OBJECT

START_OBJECT is returned when encountering '{' which signals starting of an Object value.

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.

public static final JsonToken
VALUE_FALSE

VALUE_FALSE is returned when encountering literal "false" in value context

public static final JsonToken
VALUE_NULL

VALUE_NULL is returned when encountering literal "null" in value context

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).

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).

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)

public static final JsonToken
VALUE_TRUE

VALUE_TRUE is returned when encountering literal "true" in value context

Constructor Summary

AccessConstructor and Description
private
JsonToken(String
representation for this token, if there is a single static representation; null otherwise
token
,
int
Numeric id from JsonTokenId
id
)

Method Summary

Modifier and TypeMethod and Description
public final byte[]
public final char[]
public final String
public final int
id()

public final boolean

Returns:

True if this token is VALUE_TRUE or VALUE_FALSE, false otherwise
isBoolean
()

public final boolean

Returns:

True if this token is VALUE_NUMBER_INT or VALUE_NUMBER_FLOAT, false otherwise
isNumeric
()

public final boolean

Returns:

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

Method that can be used to check whether this token represents a valid non-structured value.

public final boolean

Returns:

True if this token is END_OBJECT or END_ARRAY, false otherwise
isStructEnd
()

Accessor that is functionally equivalent to: this == JsonToken.END_OBJECT || this == JsonToken.END_ARRAY

public final boolean

Returns:

True if this token is START_OBJECT or START_ARRAY, false otherwise
isStructStart
()

Accessor that is functionally equivalent to: this == JsonToken.START_OBJECT || this == JsonToken.START_ARRAY

public static String

Returns:

String description of given token
valueDescFor
(JsonToken
Token to get description for
t
)

Helper method for constructing description like "Object value" given JsonToken encountered.

public static JsonToken
public static JsonToken[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

_idback to summary
pack-priv final int _id
_isBooleanback to summary
pack-priv final boolean _isBoolean
_isNumberback to summary
pack-priv final boolean _isNumber
_isScalarback to summary
pack-priv final boolean _isScalar
_isStructEndback to summary
pack-priv final boolean _isStructEnd
_isStructStartback to summary
pack-priv final boolean _isStructStart
_serializedback to summary
pack-priv final String _serialized
_serializedBytesback to summary
pack-priv final byte[] _serializedBytes
_serializedCharsback to summary
pack-priv final char[] _serializedChars
END_ARRAYback to summary
public static final JsonToken END_ARRAY

END_ARRAY is returned when encountering ']' which signals ending of an Array value

END_OBJECTback to summary
public static final JsonToken END_OBJECT

END_OBJECT is returned when encountering '}' which signals ending of an Object value

FIELD_NAMEback to summary
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)

NOT_AVAILABLEback to summary
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_ARRAYback to summary
public static final JsonToken START_ARRAY

START_ARRAY is returned when encountering '[' which signals starting of an Array value

START_OBJECTback to summary
public static final JsonToken START_OBJECT

START_OBJECT is returned when encountering '{' which signals starting of an Object value.

VALUE_EMBEDDED_OBJECTback to summary
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_FALSEback to summary
public static final JsonToken VALUE_FALSE

VALUE_FALSE is returned when encountering literal "false" in value context

VALUE_NULLback to summary
public static final JsonToken VALUE_NULL

VALUE_NULL is returned when encountering literal "null" in value context

VALUE_NUMBER_FLOATback to summary
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_NUMBER_INTback to summary
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_STRINGback to summary
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_TRUEback to summary
public static final JsonToken VALUE_TRUE

VALUE_TRUE is returned when encountering literal "true" in value context

Constructor Detail

JsonTokenback to summary
private JsonToken(String token, int id)
Parameters
token:String

representation for this token, if there is a single static representation; null otherwise

id:int

Numeric id from JsonTokenId

Method Detail

asByteArrayback to summary
public final byte[] asByteArray()
asCharArrayback to summary
public final char[] asCharArray()
asStringback to summary
public final String asString()
idback to summary
public final int id()
isBooleanback to summary
public final boolean isBoolean()
Returns:boolean

True if this token is VALUE_TRUE or VALUE_FALSE, false otherwise

isNumericback to summary
public final boolean isNumeric()
Returns:boolean

True if this token is VALUE_NUMBER_INT or VALUE_NUMBER_FLOAT, false otherwise

isScalarValueback to summary
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:boolean

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

isStructEndback to summary
public final boolean isStructEnd()

Accessor that is functionally equivalent to: this == JsonToken.END_OBJECT || this == JsonToken.END_ARRAY

Returns:boolean

True if this token is END_OBJECT or END_ARRAY, false otherwise

Since
2.3
isStructStartback to summary
public final boolean isStructStart()

Accessor that is functionally equivalent to: this == JsonToken.START_OBJECT || this == JsonToken.START_ARRAY

Returns:boolean

True if this token is START_OBJECT or START_ARRAY, false otherwise

Since
2.3
valueDescForback to summary
public static String valueDescFor(JsonToken t)

Helper method for constructing description like "Object value" given JsonToken encountered.

Parameters
t:JsonToken

Token to get description for

Returns:String

String description of given token

Since
2.16
valueOfback to summary
public static JsonToken valueOf(String name)
valuesback to summary
public static JsonToken[] values()