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

question: Dynamic Object Transform #1394

Open
dima-getselectstar opened this issue Nov 22, 2022 · 1 comment
Open

question: Dynamic Object Transform #1394

dima-getselectstar opened this issue Nov 22, 2022 · 1 comment
Labels
type: question Questions about the usage of the library.

Comments

@dima-getselectstar
Copy link

I was trying to transform dynamic object props, but can't figure it out. Let's assume we have an object with dynamic props as following:

info_details: {[randomId]: {user_names: [ 'Julia', 'Alex' ] } }

The problem:

Normally we would use something like this:

class A {
  @Expose({ name: 'user_names' })
  userNames!: string[];
}

class B {
  @Expose({ name: 'info_details' })
  @Type(() => A)
  infoDetails!: A;
}

But in the case when randomId is a dynamic prop and we cannot define a class to it I don't really know what would be the best way to parse that object. Could you help please?

@dima-getselectstar dima-getselectstar added the type: question Questions about the usage of the library. label Nov 22, 2022
@diffy0712
Copy link

Hello @dima-getselectstar,

you will not be able to assign and transform to a type you do not know. Your option is to use a simple object here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Questions about the usage of the library.
Development

No branches or pull requests

2 participants