public interface EntitySerialization
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ENTITY_NAME_PROP |
static java.lang.String |
INSTANCE_NAME_PROP |
Modifier and Type | Method and Description |
---|---|
<T> java.util.Collection<T> |
entitiesCollectionFromJson(java.lang.String json,
MetaClass metaClass,
EntitySerializationOption... options)
Deserializes a JSON array of objects to entities collection
|
<T> T |
entityFromJson(java.lang.String json,
MetaClass metaClass,
EntitySerializationOption... options)
Deserializes a JSON object to the entity.
|
<T> T |
objectFromJson(java.lang.String json,
java.lang.reflect.Type type,
EntitySerializationOption... options)
Deserializes an object of any class from JSON.
|
java.lang.String |
objectToJson(java.lang.Object object,
EntitySerializationOption... options)
Serializes any custom POJO or collection of POJOs or JSON.
|
java.lang.String |
toJson(java.util.Collection<?> entities)
An overloaded version of the
toJson(Collection, FetchPlan, EntitySerializationOption...) method with a null
fetchPlan parameter and with no serialization options. |
java.lang.String |
toJson(java.util.Collection<?> entities,
FetchPlan fetchPlan,
EntitySerializationOption... options)
Serializes a collection of entities to the JSON array.
|
java.lang.String |
toJson(java.lang.Object entity)
An overloaded version of the
toJson(Object, FetchPlan, EntitySerializationOption...) method with a null
fetchPlan parameter and with no serialization options. |
java.lang.String |
toJson(java.lang.Object entity,
FetchPlan fetchPlan,
EntitySerializationOption... options)
Serializes a single entity to the JSON object graph.
|
static final java.lang.String ENTITY_NAME_PROP
static final java.lang.String INSTANCE_NAME_PROP
java.lang.String toJson(java.lang.Object entity, @Nullable FetchPlan fetchPlan, EntitySerializationOption... options)
If the fetchPlan
parameter is null then all loaded entity properties will be presented in JSON, otherwise only
loaded properties that are in the fetchPlan will be in the JSON object.
The options
parameter specify some additional options for the serialization process. For example,
repeated entities may be replaced with the object with the only "id" property, making the result JSON more
compact. See EntitySerializationOption
for details.
Additionally, an "_entityName" property is added to the JSON objects that represent an entity.
entity
- an entity to be serializedfetchPlan
- a fetch plan that defines which entity properties should be added to the result JSON objectoptions
- options specifying how an entity should be serializedjava.lang.String toJson(java.util.Collection<?> entities, @Nullable FetchPlan fetchPlan, EntitySerializationOption... options)
toJson(Object, FetchPlan,
EntitySerializationOption...)
, but return a JSON array as a result.entities
- a list of entities to be serializedfetchPlan
- a fetch plan that defines which entity properties should be added to the result JSON objectoptions
- options specifying how an entity should be serializedjava.lang.String toJson(java.lang.Object entity)
toJson(Object, FetchPlan, EntitySerializationOption...)
method with a null
fetchPlan
parameter and with no serialization options.entity
- an entity to be serializedjava.lang.String toJson(java.util.Collection<?> entities)
toJson(Collection, FetchPlan, EntitySerializationOption...)
method with a null
fetchPlan
parameter and with no serialization options.entities
- a collection of entities to be serializedjava.lang.String objectToJson(java.lang.Object object, EntitySerializationOption... options)
DateTimeDatatype
.object
- any POJO or collection of POJOsoptions
- options specifying how a JSON object graph for fields with type 'Entity' will be serialized<T> T entityFromJson(java.lang.String json, @Nullable MetaClass metaClass, EntitySerializationOption... options)
The metaClass
parameter defines a result entity metaClass. It is optional. It must be defined if the JSON
object doesn't contain an "_entityName" property.
An entity may be serialized to the JSON in slightly different formats. The format is defined by the options
parameter. See EntitySerializationOption
for details.
json
- a string that represents a JSON objectmetaClass
- a metaClass of the entity that will be createdoptions
- options specifying how a JSON object graph was serialized<T> java.util.Collection<T> entitiesCollectionFromJson(java.lang.String json, @Nullable MetaClass metaClass, EntitySerializationOption... options)
json
- a string that represents a JSON array of objectsmetaClass
- a metaClass of the entities that will be createdoptions
- options specifying how a JSON object graph was serialized<T> T objectFromJson(java.lang.String json, java.lang.reflect.Type type, EntitySerializationOption... options)
DateTimeDatatype
format, entities object and fields of Entity type are
deserialized like in the entityFromJson(String, MetaClass, EntitySerializationOption...)
methodjson
- a string that represents an objecttype
- type of the objectoptions
- options specifying how a JSON object graph was serialized