Interface SqlJsonValueMapper
public interface SqlJsonValueMapper
The SQL JSON parameter value mapper. Default implementation which converts object to a JSON string.
- Since:
- 4.0.0
- Author:
- radovanradic
-
Method Summary
Modifier and TypeMethodDescription@NonNull io.micronaut.json.JsonMapper
default Object
mapValue
(Object object, JsonDataType jsonDataType) Converts an object to JSON using json mapper.default boolean
supportsMapValue
(SqlStoredQuery<?, ?> sqlStoredQuery, JsonDataType jsonDataType) Gets an indicator telling whether mapper can map parameter value to JSON for given SQL stored query and parameter and object being mapped.
-
Method Details
-
mapValue
Converts an object to JSON using json mapper. Default implementation produces JSON string, other implementation may return byte array etc.- Parameters:
object
- object of to convert to JSONjsonDataType
- the JSON representation object needs to be serialized to- Returns:
- the JSON created from the object using json mapper
- Throws:
IOException
- exception that can be thrown when encoding JSON
-
supportsMapValue
Gets an indicator telling whether mapper can map parameter value to JSON for given SQL stored query and parameter and object being mapped.- Parameters:
sqlStoredQuery
- the SQL stored query being executed that needs to convert JSON parameterjsonDataType
- the JSON representation type- Returns:
- true if mapper can map parameter to JSON in context of given SQL stored query
-
getJsonMapper
@NonNull @NonNull io.micronaut.json.JsonMapper getJsonMapper()- Returns:
- the json mapper
-