com.vaadin.flow.internal.
Class JsonSerializer
- java.lang.Object
 - 
- com.vaadin.flow.internal.JsonSerializer
 
 
- 
public final class JsonSerializer extends ObjectGeneral-purpose serializer of Java objects to
JsonValueand deserializer of JsonValue to Java objects.Since:
1.0
 
- 
- 
Method Summary
All Methods Modifier and Type Method and Description static elemental.json.JsonArraytoJson(Collection<?> beans)Converts a collection of object into a
JsonArray, converting each item of the collection individually.static elemental.json.JsonValuetoJson(Object bean)Converts a Java bean,
JsonSerializableinstance, String, wrapper of primitive type or enum to aJsonValue.static <T> TtoObject(Class<T> type, elemental.json.JsonValue json)Converts a JsonValue to the corresponding Java object.
static <T> List<T>toObjects(Class<T> type, elemental.json.JsonArray json)Converts a JsonArray into a collection of Java objects.
 
 - 
 
- 
- 
Method Detail
- 
toJson
public static elemental.json.JsonValue toJson(Object bean)Converts a Java bean,
JsonSerializableinstance, String, wrapper of primitive type or enum to aJsonValue.When a bean is used, a
JsonObjectis returned.Parameters:
bean- Java object to be convertedReturns:
the json representation of the Java object
 
- 
toJson
public static elemental.json.JsonArray toJson(Collection<?> beans)Converts a collection of object into a
JsonArray, converting each item of the collection individually.Parameters:
beans- the collection of objects to be convertedReturns:
the json representation of the objects in the collectios. An empty array is returned if the input collections is
null 
- 
toObject
public static <T> T toObject(Class<T> type, elemental.json.JsonValue json)Converts a JsonValue to the corresponding Java object. The Java object can be a Java bean,
JsonSerializableinstance, String, wrapper of primitive types or an enum.Type Parameters:
T- the resulting object typeParameters:
type- the type of the Java object convert the json tojson- the json representation of the objectReturns:
the deserialized object, or
nullif the input json isnull 
- 
toObjects
public static <T> List<T> toObjects(Class<T> type, elemental.json.JsonArray json)Converts a JsonArray into a collection of Java objects. The Java objects can be Java beans,
JsonSerializableinstances, Strings, wrappers of primitive types or enums.Type Parameters:
T- the resulting objects typesParameters:
type- the type of the elements in the arrayjson- the json representation of the objectsReturns:
a modifiable list of converted objects. Returns an empty list if the input array is
null 
 - 
 
 -