Skip to content

Can't use deserializeObject if that class has a manual a constructor method implemented. #47

Open
@magtastic

Description

@magtastic

I have this class that looks something like this:

@JsonObject
export class UserPublicProfile implements RefBalrogModel {
  @JsonProperty('timestamp', TimestampConverter)
  timestamp: Timestamp = new Timestamp();

  @JsonProperty('user_name', String)
  user_name: string = undefined;

  @JsonProperty('user_id', UserIDConverter)
  user_id: UserID = undefined;

  @JsonProperty('display_name', String)
  display_name?: string = undefined;

  public static reference = DatabaseReference.publicProfile;

  constructor(user_id: UserID, user_name: string, timestamp: Timestamp, display_name?: string) {
    this.timestamp = timestamp;
    this.user_id = user_id;
    this.user_name = user_name;
    this.display_name = display_name;
  }
}

and when trying to deserialize a json object to that UserPublicProfile I get the following error:
Argument of type 'typeof UserPublicProfile' is not assignaable to parameter of type 'new () => any'.

I want to be able to initialize the object with parameters, and a jsonObject. Is that not possible with this package?

Metadata

Metadata

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions