public class JsonUtil
extends java.lang.Object
Constructor and Description |
---|
JsonUtil() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
convertJavaObjectToJson(java.lang.Object jsonJavaObject)
Converts an Object to a JSON interpretation of that object.
|
static <T> T |
convertJsonToJavaObject(java.lang.String jsonString,
java.lang.Class<T> type)
Converts a JSON to an Object of type T, which is an interpretation of that JSON string.
|
static <T> T |
readJsonFromFile(java.lang.String fileLocation,
java.lang.Class<T> type)
Reads a JSON file at the specified location and returns an Object of the class type
specified representing the JSON file attributes and values.
|
static <T> T |
readJsonFromIFile(IFile json,
java.lang.Class<T> type)
Reads a JSON file specified in the IFile and returns an Object of the class type
specified representing the JSON file attributes and values.
|
static void |
writeJsonToFile(java.io.File fileDestination,
java.lang.Object jsonJavaObject) |
static void |
writeJsonToFile(java.lang.String fileDestination,
java.lang.Object jsonJavaObject)
Writes a JSON file representation of the Object received at the specified destination.
|
public static <T> T readJsonFromFile(java.lang.String fileLocation, java.lang.Class<T> type) throws java.io.FileNotFoundException
fileLocation
- The absolute path of the JSON filetype
- Class type to be use to represent the JSON format filejava.io.FileNotFoundException
public static <T> T readJsonFromIFile(IFile json, java.lang.Class<T> type)
json
- The IFIle containing the JSON filetype
- Class type to be use to map the json attribute:value pairspublic static void writeJsonToFile(java.lang.String fileDestination, java.lang.Object jsonJavaObject) throws java.io.IOException
fileDestination
- Absolute path where the JSON file will be written.jsonJavaObject
- The object to be represented as a JSON.java.io.IOException
- if the named file exists but is a directory rather than a regular file,
does not exist but cannot be created, or cannot be opened for any other reason.public static void writeJsonToFile(java.io.File fileDestination, java.lang.Object jsonJavaObject) throws java.io.IOException
java.io.IOException
public static java.lang.String convertJavaObjectToJson(java.lang.Object jsonJavaObject)
jsonJavaObject
- The object to be converted.public static <T> T convertJsonToJavaObject(java.lang.String jsonString, java.lang.Class<T> type)
jsonString
- JSON format string.type
- Class type to be use to represent the JSON format stringCopyright (c) IBM Corp. and others 2000, 2016. All Rights Reserved.