Class JacksonHelper
java.lang.Object
com.github.thought2code.mcp.annotated.util.JacksonHelper
Helper class for Jackson JSON and YAML serialization and deserialization.
This class provides static methods for serializing and deserializing objects to and from JSON and YAML formats using Jackson.
- Author:
- codeboyzhou
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TDeserialize a JSON string to an object of the specified type.static <T> TDeserialize a YAML file to an object of the specified type.static StringtoJsonString(Object object) Serialize an object to a JSON string.
-
Method Details
-
toJsonString
Serialize an object to a JSON string.- Parameters:
object- the object to serialize- Returns:
- the JSON string representation of the object
-
fromJson
Deserialize a JSON string to an object of the specified type.- Type Parameters:
T- the type of the object to deserialize to- Parameters:
json- the JSON string to deserializevalueType- the class of the object to deserialize to- Returns:
- the deserialized object
-
fromYaml
Deserialize a YAML file to an object of the specified type.- Type Parameters:
T- the type of the object to deserialize to- Parameters:
yamlFile- the YAML file to deserializevalueType- the class of the object to deserialize to- Returns:
- the deserialized object
-