public class JsonTemplateMapper extends 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(String jsonString,
Class<T> templateClass)
Deserializes a JSON object from a JSON string.
|
static <T extends JsonTemplate> |
readJsonFromFile(Path jsonFile,
Class<T> templateClass)
Deserializes a JSON file via a JSON object template.
|
static Blob |
toBlob(JsonTemplate template)
Convert a
JsonTemplate to a Blob of the JSON string. |
public static <T extends JsonTemplate> T readJsonFromFile(Path jsonFile, Class<T> templateClass) throws IOException
jsonFile - a file containing a JSON stringtemplateClass - the template to deserialize the string tojsonFileIOException - if an error occurred during reading the file or parsing the JSONpublic static <T extends JsonTemplate> T readJson(String jsonString, Class<T> templateClass) throws IOException
IOExceptionpublic static Blob toBlob(JsonTemplate template)
JsonTemplate to a Blob of the JSON string.Copyright © 2018. All rights reserved.