Package io.vertx.core.parsetools

## Interface JsonEvent

-     public interface JsonEvent

  A JSON event emited by the `JsonParser`.
  Author:
    Julien Viet

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `JsonArray` | `arrayValue()` |
    `Buffer` | `binaryValue()` | Return the binary value.
    `Boolean` | `booleanValue()` |
    `Double` | `doubleValue()` |
    `String` | `fieldName()` |
    `Float` | `floatValue()` |
    `java.time.Instant` | `instantValue()` | Return the `Instant` value.
    `Integer` | `integerValue()` |
    `boolean` | `isArray()` |
    `boolean` | `isBoolean()` |
    `boolean` | `isNull()` |
    `boolean` | `isNumber()` |
    `boolean` | `isObject()` |
    `boolean` | `isString()` |
    `Long` | `longValue()` |
    `<T> T` | `mapTo​(TypeReference<T> type)` | Decodes and returns the current value as the specified `type`.
    `<T> T` | `mapTo​(Class<T> type)` | Decodes and returns the current value as the specified `type`.
    `JsonObject` | `objectValue()` |
    `String` | `stringValue()` |
    `JsonEventType` | `type()` |
    `Object` | `value()` |

- - ### Method Detail

    - #### type

          JsonEventType type()

      Returns:
        the type of the event

    - #### fieldName

          String fieldName()

      Returns:
        the name of the field when the event is emitted as a JSON object member

    - #### value

          Object value()

      Returns:
        the json value for `JsonEventType.VALUE` events

    - #### isNumber

          boolean isNumber()

      Returns:
        true when the JSON value is a number

    - #### integerValue

          Integer integerValue()

      Returns:
        the `Integer` value or `null` if the event has no JSON value
      Throws:
        `ClassCastException` - if the value is not an `Integer`

    - #### longValue

          Long longValue()

      Returns:
        the `Long` value or `null` if the event has no JSON value
      Throws:
        `ClassCastException` - if the value is not a `Long`

    - #### floatValue

          Float floatValue()

      Returns:
        the `Float` value or `null` if the event has no JSON value
      Throws:
        `ClassCastException` - if the value is not a `Float`

    - #### doubleValue

          Double doubleValue()

      Returns:
        the `Double` value or `null` if the event has no JSON value
      Throws:
        `ClassCastException` - if the value is not a `Double`

    - #### isBoolean

          boolean isBoolean()

      Returns:
        true when the JSON value is a boolean

    - #### booleanValue

          Boolean booleanValue()

      Returns:
        the `Boolean` value or `null` if the event has no JSON value
      Throws:
        `ClassCastException` - if the value is not a `Boolean`

    - #### isString

          boolean isString()

      Returns:
        true when the JSON value is a string

    - #### stringValue

          String stringValue()

      Returns:
        the string value or `null` if the event has no JSON value
      Throws:
        `ClassCastException` - if the value is not a string

    - #### binaryValue

          Buffer binaryValue()

      Return the binary value.

      JSON itself has no notion of a binary, this extension complies to the RFC-7493, so this method assumes there is a String value with the key and it contains a Base64 encoded binary, which it decodes if found and returns.

      Returns:
        the binary value or `null` if the event has no JSON value
      Throws:
        `ClassCastException` - if the value is not a String
        `IllegalArgumentException` - if the String value is not a legal Base64 encoded value

    - #### instantValue

          java.time.Instant instantValue()

      Return the `Instant` value.

      JSON itself has no notion of a temporal types, this extension complies to the RFC-7493, so this method assumes there is a String value with the key and it contains an ISO 8601 encoded date and time format such as "2017-04-03T10:25:41Z", which it decodes if found and returns.

      Returns:
        the `Instant` value or `null` if the event has no JSON value
      Throws:
        `ClassCastException` - if the value is not a String
        `java.time.format.DateTimeParseException` - if the String value is not a legal ISO 8601 encoded value

    - #### isNull

          boolean isNull()

      Returns:
        true when the JSON value is null

    - #### isObject

          boolean isObject()

      Returns:
        true when the JSON value is a JSON object

    - #### objectValue

          JsonObject objectValue()

      Returns:
        the JSON object value or `null` if the event has no JSON value
      Throws:
        `ClassCastException` - if the value is not a JSON object

    - #### isArray

          boolean isArray()

      Returns:
        true when the JSON value is a JSON array

    - #### arrayValue

          JsonArray arrayValue()

      Returns:
        the JSON array value or `null` if the event has no JSON value
      Throws:
        `ClassCastException` - if the value is not a JSON array

    - #### mapTo

          <T> T mapTo​(Class<T> type)

      Decodes and returns the current value as the specified `type`.
      Parameters:
        `type` - the type to decode the value to
      Returns:
        the decoded value

    - #### mapTo

          <T> T mapTo​(TypeReference<T> type)

      Decodes and returns the current value as the specified `type`.
      Parameters:
        `type` - the type to decode the value to
      Returns:
        the decoded value