T - Type to marshal.@InterfaceAudience.Private
@InterfaceStability.Evolving
public class JsonSerDeser<T>
extends org.apache.hadoop.util.JsonSerialization<T>
This extends JsonSerialization with the notion
of a marker field in the JSON file, with
| Modifier and Type | Field and Description |
|---|---|
static String |
E_DATA_TOO_SHORT |
static String |
E_MISSING_MARKER_STRING |
static String |
E_NO_DATA |
| Constructor and Description |
|---|
JsonSerDeser(Class<T> classType)
Create an instance bound to a specific type
|
| Modifier and Type | Method and Description |
|---|---|
T |
fromBytes(String path,
byte[] bytes)
Deserialize from a byte array
|
T |
fromBytes(String path,
byte[] bytes,
String marker)
Deserialize from a byte array, optionally checking for a marker string.
|
public static final String E_NO_DATA
public static final String E_DATA_TOO_SHORT
public static final String E_MISSING_MARKER_STRING
public T fromBytes(String path, byte[] bytes) throws IOException
path - path the data came frombytes - byte arrayIOException - all problemsEOFException - not enough dataInvalidRecordException - if the parsing failed -the record is invalidNoRecordException - if the data is not considered a record: either
it is too short or it did not contain the marker string.public T fromBytes(String path, byte[] bytes, String marker) throws IOException
If the marker parameter is supplied (and not empty), then its presence
will be verified before the JSON parsing takes place; it is a fast-fail
check. If not found, an InvalidRecordException exception will be
raised
path - path the data came frombytes - byte arraymarker - an optional string which, if set, MUST be present in the
UTF-8 parsed payload.IOException - all problemsEOFException - not enough dataInvalidRecordException - if the JSON parsing failed.NoRecordException - if the data is not considered a record: either
it is too short or it did not contain the marker string.Copyright © 2008–2022 Apache Software Foundation. All rights reserved.