-
Notifications
You must be signed in to change notification settings - Fork 35
RFC: VertxGen as data object
In Vert.x 3, @VertxGen
and @DataObject
are two separate kind of objects. Some @VertxGen
annotated object represent data such as Buffer
, MultiMap
or SocketAddress
.
Allowing such types to be convertible to JSON would enable:
- using them in
DataObject
(converter generation would handle them) - allow usage in service proxies
Transform DataObjectTypeInfo
type to DataObjectInfo
, this class is not anymore part of the TypeInfo
hierarchy and instead becomes a field of ClassTypeInfo
.
@DataObject
annotated interfaces providing a static fromJson
method are recognised as equivalent of the JsonObject
constructor in @DataObject
classes.
@DataObject
toJson
and fromJson
method can define any JSON type (i.e JsonObject
, String
, etc...).
Update the service proxy and data object generators to handle such types.
Buffer
currently defines a toJson()
method that has a different meaning than the one of this proposal. It will do a best effort to parse the content and return an appropriate object, i.e it will map the 1
string to 1
integer, etc...
Proposal is to provide a new mapToJson()
method that does the same and use toJson()
to encode the buffer to B64:
-
toJson()
becomesmapToJson()
-
toJsonObject()
becomesmapToJsonObject()
-
toJsonArray()
becomesmapToJsonArray()
-
toJson()
returnsjava.lang.String
and perform B64 conversion -
fromJson(String s)
transforms a B64 encoded string to a buffer
1+2+3 will also be handled in Vert.x 3.x as part of the deprecation cycle.
Annotated as @DataObject
Annotated as @DataObject