io.vertx.core.json

## Class Json

- java.lang.Object
- - io.vertx.core.json.Json

-     public class Json
      extends Object

  Author:
    Tim Fox

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static ObjectMapper` | `mapper`
    `static ObjectMapper` | `prettyMapper`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Json()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> T` | `decodeValue(Buffer buf, Class<T> clazz)` Decode a given JSON buffer to a POJO of the given class type.
    `static <T> T` | `decodeValue(Buffer buf, TypeReference<T> type)` Decode a given JSON buffer to a POJO of the given class type.
    `static <T> T` | `decodeValue(String str, Class<T> clazz)` Decode a given JSON string to a POJO of the given class type.
    `static <T> T` | `decodeValue(String str, TypeReference<T> type)` Decode a given JSON string to a POJO of the given type.
    `static String` | `encode(Object obj)` Encode a POJO to JSON using the underlying Jackson mapper.
    `static String` | `encodePrettily(Object obj)` Encode a POJO to JSON with pretty indentation, using the underlying Jackson mapper.
    `static Buffer` | `encodeToBuffer(Object obj)` Encode a POJO to JSON using the underlying Jackson mapper.

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### mapper

          public static ObjectMapper mapper

    - #### prettyMapper

          public static ObjectMapper prettyMapper

  - ### Constructor Detail

    - #### Json

          public Json()

  - ### Method Detail

    - #### encode

          public static String encode(Object obj)
                               throws EncodeException

      Encode a POJO to JSON using the underlying Jackson mapper.
      Parameters:
        `obj` - a POJO
      Returns:
        a String containing the JSON representation of the given POJO.
      Throws:
        `EncodeException` - if a property cannot be encoded.

    - #### encodeToBuffer

          public static Buffer encodeToBuffer(Object obj)
                                       throws EncodeException

      Encode a POJO to JSON using the underlying Jackson mapper.
      Parameters:
        `obj` - a POJO
      Returns:
        a Buffer containing the JSON representation of the given POJO.
      Throws:
        `EncodeException` - if a property cannot be encoded.

    - #### encodePrettily

          public static String encodePrettily(Object obj)
                                       throws EncodeException

      Encode a POJO to JSON with pretty indentation, using the underlying Jackson mapper.
      Parameters:
        `obj` - a POJO
      Returns:
        a String containing the JSON representation of the given POJO.
      Throws:
        `EncodeException` - if a property cannot be encoded.

    - #### decodeValue

          public static <T> T decodeValue(String str,
                                          Class<T> clazz)
                                   throws DecodeException

      Decode a given JSON string to a POJO of the given class type.
      Type Parameters:
        `T` - the generic type.
      Parameters:
        `str` - the JSON string.
        `clazz` - the class to map to.
      Returns:
        an instance of T
      Throws:
        `DecodeException` - when there is a parsing or invalid mapping.

    - #### decodeValue

          public static <T> T decodeValue(String str,
                                          TypeReference<T> type)
                                   throws DecodeException

      Decode a given JSON string to a POJO of the given type.
      Type Parameters:
        `T` - the generic type.
      Parameters:
        `str` - the JSON string.
        `type` - the type to map to.
      Returns:
        an instance of T
      Throws:
        `DecodeException` - when there is a parsing or invalid mapping.

    - #### decodeValue

          public static <T> T decodeValue(Buffer buf,
                                          TypeReference<T> type)
                                   throws DecodeException

      Decode a given JSON buffer to a POJO of the given class type.
      Type Parameters:
        `T` - the generic type.
      Parameters:
        `buf` - the JSON buffer.
        `type` - the type to map to.
      Returns:
        an instance of T
      Throws:
        `DecodeException` - when there is a parsing or invalid mapping.

    - #### decodeValue

          public static <T> T decodeValue(Buffer buf,
                                          Class<T> clazz)
                                   throws DecodeException

      Decode a given JSON buffer to a POJO of the given class type.
      Type Parameters:
        `T` - the generic type.
      Parameters:
        `buf` - the JSON buffer.
        `clazz` - the class to map to.
      Returns:
        an instance of T
      Throws:
        `DecodeException` - when there is a parsing or invalid mapping.

Copyright © 2017. All rights reserved.