Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataObjects do not fully support static deserializer fromJson(JsonObject json) #389

Closed
babsher opened this issue Aug 22, 2024 · 1 comment
Assignees
Labels

Comments

@babsher
Copy link

babsher commented Aug 22, 2024

Questions

Do not use this issue tracker to ask questions, instead use one of these channels. Questions will likely be closed without notice.

Version

4.5.9

Context

I have been trying to use service proxies and DataObjects but I have found it difficult to implement the json deserializer as a constructor. I am using lombok @Value which dont seem to be compatible with @JsonGen and I would like to use something more flexible than writing all the serializers myself.

I noticed in the @DataObject annotated types section it mentions there is a static factory method fromJson(JsonObject json) which can be used. When I tried to implement this the code generation didnt pick this up as a deserializer. I looked into the code and found many places where the JsonObject constructor is assumed instead of checking for the static factory.

It looks like the TypeMirrorFactory.java around line 159 seems to be the source of the issue however there are many other places this constructor is assumed.

Do you have a reproducer?

It can be reproduced by creating a DataObject as follows:

@DataObject
public MyDataObject {
  String name;

  public static MyDataObject fromJson(JsonObject json) {
    return json.mapTo(MyDataObject.class);
  }

  public JsonObject toJson() {
    new JsonObject("name", this.name);
  }
}

Steps to reproduce

  1. Run vertx-codegen annotation processor
@babsher babsher added the bug label Aug 22, 2024
@vietj
Copy link
Member

vietj commented Sep 26, 2024

#376

@vietj vietj closed this as completed Sep 26, 2024
@vietj vietj reopened this Sep 26, 2024
@vietj vietj closed this as completed Sep 26, 2024
@vietj vietj self-assigned this Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants