Class JsonUtils

java.lang.Object
de.hybris.platform.searchservices.util.JsonUtils

public final class JsonUtils extends Object
JSON utilities.
  • Method Summary

    Modifier and Type
    Method
    Description
    static final <T> T
    fromJson(String source, com.fasterxml.jackson.core.type.TypeReference<T> valueType)
    Converts a JSON string to an object.
    static final <T> T
    fromJson(String source, com.fasterxml.jackson.core.type.TypeReference<T> valueType, Map<String,String> parameters)
    Converts a JSON string to an object, using variable substitution.
    static final <T> T
    fromJson(String source, Class<T> valueType)
    Converts a JSON string to an object.
    static final <T> T
    fromJson(String source, Class<T> valueType, Map<String,String> parameters)
    Converts a JSON string to an object, using variable substitution.
    static final <T> T
    loadJson(String resource, com.fasterxml.jackson.core.type.TypeReference<T> valueType)
    Loads a JSON string from a file and converts it to an object.
    static final <T> T
    loadJson(String resource, com.fasterxml.jackson.core.type.TypeReference<T> valueType, Map<String,String> parameters)
    Loads a JSON string from a file and converts it to an object, using variable substitution.
    static final <T> T
    loadJson(String resource, Class<T> valueType)
    Loads a JSON string from a file and converts it to an object.
    static final <T> T
    loadJson(String resource, Class<T> valueType, Map<String,String> parameters)
    Loads a JSON string from a file and converts it to an object, using variable substitution.
    static final String
    toJson(Object source)
    Converts an object to a JSON string.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • toJson

      public static final String toJson(Object source)
      Converts an object to a JSON string.
      Parameters:
      source - - the source object
      Returns:
      a JSON string
    • fromJson

      public static final <T> T fromJson(String source, Class<T> valueType)
      Converts a JSON string to an object.
      Type Parameters:
      T - - the type of the target object
      Parameters:
      source - - the source JSON string
      valueType - - the value type of the target object
      Returns:
      an object
    • fromJson

      public static final <T> T fromJson(String source, Class<T> valueType, Map<String,String> parameters)
      Converts a JSON string to an object, using variable substitution.
      Type Parameters:
      T - - the type of the target object
      Parameters:
      source - - the source JSON string
      valueType - - the value type of the target object
      parameters - - the parameters used for variable substitution
      Returns:
      an object
    • fromJson

      public static final <T> T fromJson(String source, com.fasterxml.jackson.core.type.TypeReference<T> valueType)
      Converts a JSON string to an object.
      Type Parameters:
      T - - the type of the target object
      Parameters:
      source - - the source JSON string
      valueType - - the value type of the target object
      Returns:
      an object
    • fromJson

      public static final <T> T fromJson(String source, com.fasterxml.jackson.core.type.TypeReference<T> valueType, Map<String,String> parameters)
      Converts a JSON string to an object, using variable substitution.
      Type Parameters:
      T - - the type of the target object
      Parameters:
      source - - the source JSON string
      valueType - - the value type of the target object
      parameters - - the parameters used for variable substitution
      Returns:
      an object
    • loadJson

      public static final <T> T loadJson(String resource, Class<T> valueType)
      Loads a JSON string from a file and converts it to an object.
      Type Parameters:
      T - - the type of the target object
      Parameters:
      resource - - the resource that contains the JSON string
      valueType - - the value type of the target object
      Returns:
      an object
    • loadJson

      public static final <T> T loadJson(String resource, Class<T> valueType, Map<String,String> parameters)
      Loads a JSON string from a file and converts it to an object, using variable substitution.
      Type Parameters:
      T - - the type of the target object
      Parameters:
      resource - - the resource that contains the JSON string
      valueType - - the value type of the target object
      parameters - - the parameters used for variable substitution
      Returns:
      an object
    • loadJson

      public static final <T> T loadJson(String resource, com.fasterxml.jackson.core.type.TypeReference<T> valueType)
      Loads a JSON string from a file and converts it to an object.
      Type Parameters:
      T - - the type of the target object
      Parameters:
      resource - - the resource that contains the JSON string
      valueType - - the value type of the target object
      Returns:
      an object
    • loadJson

      public static final <T> T loadJson(String resource, com.fasterxml.jackson.core.type.TypeReference<T> valueType, Map<String,String> parameters)
      Loads a JSON string from a file and converts it to an object, using variable substitution.
      Type Parameters:
      T - - the type of the target object
      Parameters:
      resource - - the resource that contains the JSON string
      valueType - - the value type of the target object
      parameters - - the parameters used for variable substitution
      Returns:
      an object