public class JsonTemplateMapper
extends java.lang.Object
The interface uses Jackson as the JSON parser. Some useful annotations to include on classes used as templates for JSON are:
@JsonInclude(JsonInclude.Include.NON_NULL)
null.
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
| Modifier and Type | Method and Description |
|---|---|
static <T extends JsonTemplate> |
readJson(java.lang.String jsonString,
java.lang.Class<T> templateClass)
Deserializes a JSON object from a JSON string.
|
static <T extends JsonTemplate> |
readJsonFromFile(java.nio.file.Path jsonFile,
java.lang.Class<T> templateClass)
Deserializes a JSON file via a JSON object template.
|
static <T extends ListOfJsonTemplate> |
readListOfJson(java.lang.String jsonString,
java.lang.Class<T> templateClass)
Deserializes a JSON object list from a JSON string.
|
static Blob |
toBlob(JsonTemplate template)
Convert a
JsonTemplate to a Blob of the JSON string. |
static Blob |
toBlob(ListOfJsonTemplate template)
Convert a
ListOfJsonTemplate to a Blob of the JSON string. |
public static <T extends JsonTemplate> T readJsonFromFile(java.nio.file.Path jsonFile, java.lang.Class<T> templateClass) throws java.io.IOException
T - child type of JsonTemplatejsonFile - a file containing a JSON stringtemplateClass - the template to deserialize the string tojsonFilejava.io.IOException - if an error occurred during reading the file or parsing the JSONpublic static <T extends JsonTemplate> T readJson(java.lang.String jsonString, java.lang.Class<T> templateClass) throws java.io.IOException
T - child type of JsonTemplatejsonString - a JSON stringtemplateClass - the template to deserialize the string tojsonStringjava.io.IOException - if an error occurred during parsing the JSONpublic static <T extends ListOfJsonTemplate> java.util.List<T> readListOfJson(java.lang.String jsonString, java.lang.Class<T> templateClass) throws java.io.IOException
T - child type of ListOfJsonTemplatejsonString - a JSON stringtemplateClass - the template to deserialize the string tojsonFilejava.io.IOException - if an error occurred during parsing the JSONpublic static Blob toBlob(JsonTemplate template)
JsonTemplate to a Blob of the JSON string.template - the JSON template to convertBlob of the JSON stringpublic static Blob toBlob(ListOfJsonTemplate template)
ListOfJsonTemplate to a Blob of the JSON string.template - the list of JSON templates to convertBlob of the JSON string