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: Allow weakly-typed mapping via Dictionary #29825

Open
Tracked by #30731
roji opened this issue Dec 11, 2022 · 11 comments
Open
Tracked by #30731

JSON: Allow weakly-typed mapping via Dictionary #29825

roji opened this issue Dec 11, 2022 · 11 comments

Comments

@roji
Copy link
Member

roji commented Dec 11, 2022

#28871 tracks weakly-typed JSON mapping via JsonDocument/JsonElement, where the JSON document schema varies and so a strongly-typed model isn't appropriate.

We can also allow simply mapping arbitrary Dictionary types - this corresponds to how many people use

  • This intersects with #28688 (primitive collections in JSON).
  • Both keys and values should support any valid JSON data type (string, int...).
  • However we could also support Dictionary<string, object>, to map an entire hierarchy. See #26903 on this (currently seemed blocked by property bag detection).
  • This should be supported at the top-level, so that the JSON object as a whole is mapped as a single dictionary (see e.g. this issue). This would mean supporting OwnsOne(x => x.Json, builder => { builder.ToJson(); }) where x.Json is a Dictionary.
@roji
Copy link
Member Author

roji commented Dec 12, 2022

Duplicate of #29427

@roji roji marked this as a duplicate of #29427 Dec 12, 2022
@roji roji closed this as not planned Won't fix, can't repro, duplicate, stale Dec 12, 2022
@ajcvickers
Copy link
Member

Re-opening, since dictionary mapping was not covered by "primitive collections".

@vchirikov
Copy link

Link to the "issue" should be in the docs at least, was difficult to find..
Is it planned for 9.0 release?

@roji
Copy link
Member Author

roji commented Mar 20, 2024

@vchirikov the milestone generally expresses whether an issue is planned for a given release or not.

@onionhammer
Copy link

onionhammer commented Apr 18, 2024

I assume this would also meant support for ExtensionData and Dictionary<string, JsonElement> ?

@roji
Copy link
Member Author

roji commented Apr 19, 2024

@onionhammer that would be a combination of this and #28871.

@onionhammer
Copy link

onionhammer commented Apr 19, 2024

@roji putting querying aside for now, JsonElement can already be saved/serialized as an entity property, but Dictionary<string, JsonElement> cannot;

@bugproof

This comment has been minimized.

@roji

This comment has been minimized.

@bugproof

This comment has been minimized.

@roji

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants