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

atdgen: support for wrapped keys for object repr in melange #403

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

danielmercier
Copy link

@danielmercier danielmercier commented Mar 1, 2024

This PR implements support for wrapped keys when using <json repr="object">:

As a simple example:

type t =
   ( string wrap <ocaml t="int" wrap="int_of_string" unwrap="string_of_int">
   * int) list <json repr="object">

Really unsure if this is the correct approach as re-using the encoder/decoder for the name is the simplest solution I found. This emulates what is done in oj_emit.ml. But this changes the Encode/Decode APIs

@danielmercier danielmercier changed the title atdgen: add support for wrapped keys for <json repr = "object"> in melange atdgen: support for wrapped keys for object repr in melange Mar 1, 2024
@mjambon
Copy link
Collaborator

mjambon commented Apr 3, 2024

This seems like an unusual need. Wouldn't it be best served by using an adapter that rewrites the JSON object into an array of pairs? I'm worried about the maintenance burden, atdgen being already very complicated.

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

Successfully merging this pull request may close these issues.

2 participants