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

Json Flattening #62

Open
TheNitesWhoSay opened this issue Aug 21, 2020 · 1 comment
Open

Json Flattening #62

TheNitesWhoSay opened this issue Aug 21, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@TheNitesWhoSay
Copy link
Owner

RareJson should support opt-in (with annotations) flattening of super classes and nested objects.

e.g.

struct Parent { int a; ... }
struct Child : Parent { int b; ... }

Which today when writing child would come out something like...

{
  "b": 12345,
  "parent": {
    "a": 12345
  }
}

Should be possible to instead have written like...

{
  "a": 12345,
  "b": 12345
}

Some of the challenges identified earlier were as follows:

1.) Flattening should potentially apply recursively, pulling the hierarchy of ancestor classes into sub-classes if directed to do so
2.) Data-hiding and naming collisions need to be accounted for
3.) Open questions of whose field clusters unknown fields belong to
4.) There's no reason flattening couldn't also apply to regular fields of certain types, such as nested reflected objects
5.) There's a huge amount of logic changes related to pretty print and affixing that this would necessitate - you can no longer rely on analysis of the current object to tell if something is the first field

@TheNitesWhoSay TheNitesWhoSay added the enhancement New feature or request label Aug 21, 2020
@TheNitesWhoSay TheNitesWhoSay self-assigned this Sep 22, 2020
@TheNitesWhoSay
Copy link
Owner Author

Some earlier thoughts on what some of this might look like: https://godbolt.org/z/4GYnPz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant