Class JsonUtils
java.lang.Object
de.hybris.platform.searchservices.util.JsonUtils
JSON utilities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic final <T> TConverts a JSON string to an object.static final <T> TfromJson(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> TConverts a JSON string to an object.static final <T> TConverts a JSON string to an object, using variable substitution.static final <T> TLoads a JSON string from a file and converts it to an object.static final <T> TloadJson(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> TLoads a JSON string from a file and converts it to an object.static final <T> TLoads a JSON string from a file and converts it to an object, using variable substitution.static final StringConverts an object to a JSON string.
-
Method Details
-
toJson
Converts an object to a JSON string.- Parameters:
source- - the source object- Returns:
- a JSON string
-
fromJson
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(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 stringvalueType- - the value type of the target objectparameters- - 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 stringvalueType- - 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 stringvalueType- - the value type of the target objectparameters- - the parameters used for variable substitution- Returns:
- an object
-
loadJson
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(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 stringvalueType- - the value type of the target objectparameters- - 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 stringvalueType- - 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 stringvalueType- - the value type of the target objectparameters- - the parameters used for variable substitution- Returns:
- an object
-