Package com.blackrook.small.roles
Interface JSONDriver
public interface JSONDriver
Describes a JSON driver for Small.
In order to return Objects from Content-annotated, EntryPath-annotated methods, a class
that implements this class needs to be in the component search.
Only one component needs to have this role. This is used for conversion if the output content MIME-type
is application/json or no MIME-type is specified.
- Author:
- Matthew Tropiano
-
Method Summary
Modifier and TypeMethodDescription<T> TCalled when an object needs to be converted to an object from JSON.default <T> TfromJSONString(String json, Class<T> type) Converts an object to a JSON string from an object.voidCalled when an object needs to be converted to JSON from an object.default StringtoJSONString(Object object) Converts an object to a JSON string from an object.
-
Method Details
-
fromJSON
Called when an object needs to be converted to an object from JSON.- Type Parameters:
T- the return type.- Parameters:
reader- the provided reader to read JSON from.type- the target object type.- Returns:
- the converted object.
- Throws:
IOException- if an error occurs during the read.
-
toJSON
Called when an object needs to be converted to JSON from an object.- Parameters:
writer- the writer to write to.object- the object to convert and write.- Throws:
IOException- if an error occurs during the write.
-
fromJSONString
Converts an object to a JSON string from an object.- Type Parameters:
T- the type result.- Parameters:
json- the input JSON string.type- the type to convert to.- Returns:
- the resultant JSON string.
- Throws:
IOException- if an error occurs during the write.
-
toJSONString
Converts an object to a JSON string from an object.- Parameters:
object- the object to convert and write.- Returns:
- the resultant JSON string.
- Throws:
IOException- if an error occurs during the write.
-