Class JsonUtil
java.lang.Object
io.github.alejo2075.enzonasdk.util.JsonUtil
Provides utility methods for converting between JSON strings and Java objects.
This class configures the ObjectMapper to not fail on unknown properties and to format the JSON output.
Exception handling is centralized via the JsonProcessingException, providing a clear protocol for error management across JSON processing tasks.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
JsonUtil
public JsonUtil()
-
-
Method Details
-
fromJson
Deserializes a JSON string into an object of the specified Java class.- Type Parameters:
T- the type parameter indicating the type of the Java object to be returned- Parameters:
json- the JSON string to be deserializedvalueType- the class of type T to which json is to be deserialized- Returns:
- an instance of
Tpopulated with data converted from the JSON string - Throws:
JsonProcessingException- if JSON to Java object deserialization fails
-
toJson
Serializes an object into its JSON string representation.- Parameters:
value- the Java object to be serialized- Returns:
- a JSON string representation of
value - Throws:
JsonProcessingException- if object to JSON serialization fails
-