Class JsonUtils
- java.lang.Object
-
- de.hybris.platform.searchservices.util.JsonUtils
-
public final class JsonUtils extends java.lang.ObjectJSON utilities.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> TfromJson(java.lang.String source, com.fasterxml.jackson.core.type.TypeReference<T> valueType)Converts a JSON string to an object.static <T> TfromJson(java.lang.String source, com.fasterxml.jackson.core.type.TypeReference<T> valueType, java.util.Map<java.lang.String,java.lang.String> parameters)Converts a JSON string to an object, using variable substitution.static <T> TfromJson(java.lang.String source, java.lang.Class<T> valueType)Converts a JSON string to an object.static <T> TfromJson(java.lang.String source, java.lang.Class<T> valueType, java.util.Map<java.lang.String,java.lang.String> parameters)Converts a JSON string to an object, using variable substitution.static <T> TloadJson(java.lang.String resource, com.fasterxml.jackson.core.type.TypeReference<T> valueType)Loads a JSON string from a file and converts it to an object.static <T> TloadJson(java.lang.String resource, com.fasterxml.jackson.core.type.TypeReference<T> valueType, java.util.Map<java.lang.String,java.lang.String> parameters)Loads a JSON string from a file and converts it to an object, using variable substitution.static <T> TloadJson(java.lang.String resource, java.lang.Class<T> valueType)Loads a JSON string from a file and converts it to an object.static <T> TloadJson(java.lang.String resource, java.lang.Class<T> valueType, java.util.Map<java.lang.String,java.lang.String> parameters)Loads a JSON string from a file and converts it to an object, using variable substitution.static java.lang.StringtoJson(java.lang.Object source)Converts an object to a JSON string.
-
-
-
Method Detail
-
toJson
public static final java.lang.String toJson(java.lang.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(java.lang.String source, java.lang.Class<T> valueType)Converts a JSON string to an object.- Type Parameters:
T- - the type of the target object- Parameters:
source- - the source JSON stringvalueType- - the value type of the target object- Returns:
- an object
-
fromJson
public static final <T> T fromJson(java.lang.String source, java.lang.Class<T> valueType, java.util.Map<java.lang.String,java.lang.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 stringvalueType- - the value type of the target objectparameters- - the parameters used for variable substitution- Returns:
- an object
-
fromJson
public static final <T> T fromJson(java.lang.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 stringvalueType- - the value type of the target object- Returns:
- an object
-
fromJson
public static final <T> T fromJson(java.lang.String source, com.fasterxml.jackson.core.type.TypeReference<T> valueType, java.util.Map<java.lang.String,java.lang.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 stringvalueType- - the value type of the target objectparameters- - the parameters used for variable substitution- Returns:
- an object
-
loadJson
public static final <T> T loadJson(java.lang.String resource, java.lang.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 stringvalueType- - the value type of the target object- Returns:
- an object
-
loadJson
public static final <T> T loadJson(java.lang.String resource, java.lang.Class<T> valueType, java.util.Map<java.lang.String,java.lang.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 stringvalueType- - the value type of the target objectparameters- - the parameters used for variable substitution- Returns:
- an object
-
loadJson
public static final <T> T loadJson(java.lang.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 stringvalueType- - the value type of the target object- Returns:
- an object
-
loadJson
public static final <T> T loadJson(java.lang.String resource, com.fasterxml.jackson.core.type.TypeReference<T> valueType, java.util.Map<java.lang.String,java.lang.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 stringvalueType- - the value type of the target objectparameters- - the parameters used for variable substitution- Returns:
- an object
-
-