T - Type to marshal.RegistryUtils.ServiceRecordMarshal@Private
@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 | Description |
|---|---|---|
static java.lang.String |
E_DATA_TOO_SHORT |
|
static java.lang.String |
E_MISSING_MARKER_STRING |
|
static java.lang.String |
E_NO_DATA |
| Constructor | Description |
|---|---|
JsonSerDeser(java.lang.Class<T> classType) |
Create an instance bound to a specific type
|
| Modifier and Type | Method | Description |
|---|---|---|
T |
fromBytes(java.lang.String path,
byte[] bytes) |
Deserialize from a byte array
|
T |
fromBytes(java.lang.String path,
byte[] bytes,
java.lang.String marker) |
Deserialize from a byte array, optionally checking for a marker string.
|
public static final java.lang.String E_NO_DATA
public static final java.lang.String E_DATA_TOO_SHORT
public static final java.lang.String E_MISSING_MARKER_STRING
public JsonSerDeser(java.lang.Class<T> classType)
classType - class to marshallpublic T fromBytes(java.lang.String path, byte[] bytes) throws java.io.IOException
path - path the data came frombytes - byte arrayjava.io.IOException - all problemsjava.io.EOFException - 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(java.lang.String path, byte[] bytes, java.lang.String marker) throws java.io.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.java.io.IOException - all problemsjava.io.EOFException - 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–2025 Apache Software Foundation. All rights reserved.