org.keycloak.util

## Class JsonSerialization

- java.lang.Object
- - org.keycloak.util.JsonSerialization

-     public class JsonSerialization
      extends Object

  Utility class to handle simple JSON serializable for Keycloak.
  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static com.fasterxml.jackson.databind.ObjectMapper` | `mapper`
    `static com.fasterxml.jackson.databind.ObjectMapper` | `prettyMapper`
    `static com.fasterxml.jackson.databind.ObjectMapper` | `sysPropertiesAwareMapper`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JsonSerialization()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static com.fasterxml.jackson.databind.node.ObjectNode` | `createObjectNode()`
    `static com.fasterxml.jackson.databind.node.ObjectNode` | `createObjectNode(Object pojo)` Creates an `ObjectNode` based on the given `pojo`, copying all its properties to the resulting `ObjectNode`.
    `static <T> T` | `readValue(byte[] bytes, Class<T> type)`
    `static <T> T` | `readValue(InputStream bytes, Class<T> type)`
    `static <T> T` | `readValue(InputStream bytes, Class<T> type, boolean replaceSystemProperties)`
    `static <T> T` | `readValue(InputStream bytes, com.fasterxml.jackson.core.type.TypeReference<T> type)`
    `static <T> T` | `readValue(String bytes, Class<T> type)`
    `static <T> T` | `readValue(String string, com.fasterxml.jackson.core.type.TypeReference<T> type)`
    `static byte[]` | `writeValueAsBytes(Object obj)`
    `static String` | `writeValueAsPrettyString(Object obj)`
    `static String` | `writeValueAsString(Object obj)`
    `static void` | `writeValuePrettyToStream(OutputStream os, Object obj)`
    `static void` | `writeValueToStream(OutputStream os, Object obj)`

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

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

- - ### Field Detail

    - #### mapper

          public static final com.fasterxml.jackson.databind.ObjectMapper mapper

    - #### prettyMapper

          public static final com.fasterxml.jackson.databind.ObjectMapper prettyMapper

    - #### sysPropertiesAwareMapper

          public static final com.fasterxml.jackson.databind.ObjectMapper sysPropertiesAwareMapper

  - ### Constructor Detail

    - #### JsonSerialization

          public JsonSerialization()

  - ### Method Detail

    - #### writeValueToStream

          public static void writeValueToStream(OutputStream os,
                                                Object obj)
                                         throws IOException

      Throws:
        `IOException`

    - #### writeValuePrettyToStream

          public static void writeValuePrettyToStream(OutputStream os,
                                                      Object obj)
                                               throws IOException

      Throws:
        `IOException`

    - #### writeValueAsPrettyString

          public static String writeValueAsPrettyString(Object obj)
                                                 throws IOException

      Throws:
        `IOException`

    - #### writeValueAsString

          public static String writeValueAsString(Object obj)
                                           throws IOException

      Throws:
        `IOException`

    - #### writeValueAsBytes

          public static byte[] writeValueAsBytes(Object obj)
                                          throws IOException

      Throws:
        `IOException`

    - #### readValue

          public static <T> T readValue(byte[] bytes,
                                        Class<T> type)
                                 throws IOException

      Throws:
        `IOException`

    - #### readValue

          public static <T> T readValue(String bytes,
                                        Class<T> type)
                                 throws IOException

      Throws:
        `IOException`

    - #### readValue

          public static <T> T readValue(InputStream bytes,
                                        Class<T> type)
                                 throws IOException

      Throws:
        `IOException`

    - #### readValue

          public static <T> T readValue(String string,
                                        com.fasterxml.jackson.core.type.TypeReference<T> type)
                                 throws IOException

      Throws:
        `IOException`

    - #### readValue

          public static <T> T readValue(InputStream bytes,
                                        com.fasterxml.jackson.core.type.TypeReference<T> type)
                                 throws IOException

      Throws:
        `IOException`

    - #### readValue

          public static <T> T readValue(InputStream bytes,
                                        Class<T> type,
                                        boolean replaceSystemProperties)
                                 throws IOException

      Throws:
        `IOException`

    - #### createObjectNode

          public static com.fasterxml.jackson.databind.node.ObjectNode createObjectNode(Object pojo)
                                                                                 throws IOException

      Creates an `ObjectNode` based on the given `pojo`, copying all its properties to the resulting `ObjectNode`.
      Parameters:
        `pojo` - a pojo which properties will be populates into the resulting a `ObjectNode`
      Returns:
        a `ObjectNode` with all the properties from the given pojo
      Throws:
        `IOException` - if the resulting a `ObjectNode` can not be created

    - #### createObjectNode

          public static com.fasterxml.jackson.databind.node.ObjectNode createObjectNode()

Copyright © 2021 JBoss by Red Hat. All rights reserved.