Package io.mochaapi.client
Interface JsonMapper
- All Known Implementing Classes:
JacksonJsonMapper
public interface JsonMapper
Interface for JSON serialization and deserialization.
Provides methods to convert objects to JSON strings and parse JSON back to objects.
-
Method Summary
Modifier and TypeMethodDescription<T> TParses a JSON string to an object of the specified type.Converts an object to a JSON string.Parses a JSON string to a List.Parses a JSON string to a Map.
-
Method Details
-
stringify
Converts an object to a JSON string.- Parameters:
obj- the object to serialize- Returns:
- JSON string representation
- Throws:
JsonException- if serialization fails
-
parse
Parses a JSON string to an object of the specified type.- Type Parameters:
T- the target type- Parameters:
json- the JSON string to parsetype- the target class- Returns:
- the parsed object
- Throws:
JsonException- if parsing fails
-
toMap
Parses a JSON string to a Map.- Parameters:
json- the JSON string to parse- Returns:
- the parsed map
- Throws:
JsonException- if parsing fails
-
toList
Parses a JSON string to a List.- Parameters:
json- the JSON string to parse- Returns:
- the parsed list
- Throws:
JsonException- if parsing fails
-