Package org.aksw.qa.commons.load.json
Class ExtendedQALDJSONLoader
java.lang.Object
org.aksw.qa.commons.load.json.ExtendedQALDJSONLoader
Basic json load and store class using jackson.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectParses Json file and returns an Object containing the results.static Objectstatic Objectstatic ObjectreadJson(InputStream in)static ObjectreadJson(InputStream in, Class<?> type)Parses Json file and returns an Object containing the results.static byte[]Writes the json to an byte arraystatic voidLoads and saves Settings into and from json files /** Writes the given Object as JSON to location specified in File.
-
Field Details
-
LOGGER
private static org.slf4j.Logger LOGGER
-
-
Constructor Details
-
ExtendedQALDJSONLoader
private ExtendedQALDJSONLoader()Make this class non instatiable.
-
-
Method Details
-
writeJson
Loads and saves Settings into and from json files /** Writes the given Object as JSON to location specified in File. If File already exists and overwrite ==false, AttemptedOverwriteException will be thrown- Parameters:
o- The object you want to write.f- The File (-location) to save it in.overwrite- Set this true to overwrite existing file.- Throws:
IOException
-
writeJson
public static byte[] writeJson(Object json) throws com.fasterxml.jackson.core.JsonProcessingExceptionWrites the json to an byte array- Parameters:
json-- Returns:
- the given json as byte representation
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
readJson
public static Object readJson(byte[] inputJson, Class<?> type) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOExceptionParses Json file and returns an Object containing the results. You need to cast the return of this class to the class specified in type.- Parameters:
inputJson- the json to parsetype- The class type you want to read.- Returns:
- An Object you should cast.
- Throws:
IOExceptioncom.fasterxml.jackson.databind.JsonMappingExceptioncom.fasterxml.jackson.core.JsonParseException
-
readJson
public static Object readJson(InputStream in, Class<?> type) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOExceptionParses Json file and returns an Object containing the results. You need to cast the return of this class to the class specified in type.- Parameters:
f- The file location you want to read from.type- The class type you want to read.- Returns:
- An Object you should cast.
- Throws:
IOExceptioncom.fasterxml.jackson.databind.JsonMappingExceptioncom.fasterxml.jackson.core.JsonParseException
-
readJson
public static Object readJson(InputStream in) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException- Throws:
com.fasterxml.jackson.core.JsonParseExceptioncom.fasterxml.jackson.databind.JsonMappingExceptionIOException
-
readJson
- Throws:
FileNotFoundExceptionIOException
-
readJson
public static Object readJson(File f, Class<?> type) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, FileNotFoundException, IOException- Throws:
com.fasterxml.jackson.core.JsonParseExceptioncom.fasterxml.jackson.databind.JsonMappingExceptionFileNotFoundExceptionIOException
-