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

How to encode and decode a struct which has some fields that are variants? #17

Open
Mng12345 opened this issue Aug 16, 2023 · 2 comments

Comments

@Mng12345
Copy link

As the title, i have a model type t, which's definition is below:

module Product = {
  type t = VideoToGif | GifEditor | GifCompress
}

module Event = {
  type businessPoint = {
    name: string,
    data: Js.Dict.t<string>,
  }
  type t =
    | EnterPage
    | LeavePage
    | BusinessPoint(businessPoint)
}

type t = {
  event: Event.t,
  product: Product.t,
  time: string,
}

How to encode and decode the struct with type t?

@Mng12345
Copy link
Author

I just found the answer in the documentation......
doc

@Mng12345
Copy link
Author

There is still a problem that i don't know how to encode a struct with type Event.t

@Mng12345 Mng12345 reopened this Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant