T - public class JsonSerDeser<T> extends Object
| Constructor and Description |
|---|
JsonSerDeser(Class<T> classType)
Create an instance bound to a specific type
|
| Modifier and Type | Method and Description |
|---|---|
T |
fromBytes(byte[] b)
Deserialize from a byte array
|
T |
fromFile(File jsonFile)
Convert from a JSON file
|
T |
fromInstance(T instance)
clone by converting to JSON and back again.
|
T |
fromJson(String json)
Convert from JSON
|
T |
fromResource(String resource)
Convert from a JSON file
|
T |
fromStream(InputStream stream)
Convert from an input stream, closing the stream afterwards.
|
T |
load(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path)
Load from a Hadoop filesystem
|
void |
save(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path,
T instance,
boolean overwrite)
Save to a hadoop filesystem
|
void |
save(T instance,
File file)
Save an instance to a file
|
String |
toJson(T instance)
Convert an object to a JSON string
|
public T fromJson(String json) throws IOException, org.codehaus.jackson.JsonParseException, org.codehaus.jackson.map.JsonMappingException
json - inputIOException - IOorg.codehaus.jackson.map.JsonMappingException - failure to map from the JSON to this classorg.codehaus.jackson.JsonParseExceptionpublic T fromFile(File jsonFile) throws IOException, org.codehaus.jackson.JsonParseException, org.codehaus.jackson.map.JsonMappingException
jsonFile - input fileIOException - IO problemsorg.codehaus.jackson.map.JsonMappingException - failure to map from the JSON to this classorg.codehaus.jackson.JsonParseExceptionpublic T fromResource(String resource) throws IOException, org.codehaus.jackson.JsonParseException, org.codehaus.jackson.map.JsonMappingException
resource - input fileIOException - IO problemsorg.codehaus.jackson.map.JsonMappingException - failure to map from the JSON to this classorg.codehaus.jackson.JsonParseExceptionpublic T fromStream(InputStream stream) throws IOException
stream - IOException - IO problemspublic T fromInstance(T instance) throws IOException
instance - instance to duplicateIOException - problems.public T fromBytes(byte[] b) throws IOException
b - IOException - parse problemspublic T load(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) throws IOException, org.codehaus.jackson.JsonParseException, org.codehaus.jackson.map.JsonMappingException
fs - filesystempath - pathIOException - IO problemsorg.codehaus.jackson.JsonParseException - parse problemsorg.codehaus.jackson.map.JsonMappingException - O/J mapping problemspublic void save(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path,
T instance,
boolean overwrite)
throws IOException
fs - filesystempath - pathinstance - instance to saveoverwrite - should any existing file be overwrittenIOException - IO exceptionpublic void save(T instance, File file) throws IOException
instance - instance to savefile - fileIOExceptionpublic String toJson(T instance) throws IOException, org.codehaus.jackson.JsonGenerationException, org.codehaus.jackson.map.JsonMappingException
instance - instance to convertorg.codehaus.jackson.JsonParseException - parse problemsorg.codehaus.jackson.map.JsonMappingException - O/J mapping problemsIOExceptionorg.codehaus.jackson.JsonGenerationExceptionCopyright © 2014–2015 The Apache Software Foundation. All rights reserved.