com.vaadin.flow.internal.
Class JsonSerializer
General-purpose serializer of Java objects to JsonValue and
deserializer of JsonValue to Java objects.
For internal use only. May be renamed or removed in a future release.
Since:
1.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic elemental.json.JsonValueConverts a Java bean,
JsonSerializableinstance, String, wrapper of primitive type or enum to aJsonValue.static elemental.json.JsonArraytoJson(Collection<?> beans) Converts a collection of object into a
JsonArray, converting each item of the collection individually.static <T> TConverts a JsonValue to the corresponding Java object.
static <T> List<T>Converts a JsonArray into a collection of Java objects.
-
Method Details
-
toJson
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
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
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
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
-