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

Start removing JsonIn by supporting a more verbose deserialize() pattern. #51449

Merged
merged 2 commits into from
Sep 8, 2021

Conversation

akrieger
Copy link
Member

@akrieger akrieger commented Sep 7, 2021

Summary

Infrastructure "Support deserialize directly from JsonObject/Array/Value/etc"

Purpose of change

JsonIn is deprecated in #50143, which converts json loading from text to binary. Unfortunately, the entire deserialize() pattern requires accepting JsonIn as an argument. To make that change more feasible we should do as much ahead-of-time removal of JsonIn as possible.

Describe the solution

Many of the existing uses of JsonIn in the deserialize() pattern just immediately convert to a JsonObject or JsonArray, dropping into the 'object oriented' deserialize pattern off the streaming patten. We can extend JsonIn::read() to support types with a deserialize method taking either JsonIn or JsonValue-convertible types. Then we can push the actual used type into the signature and remove a large number of unnecessary references to JsonIn.

Describe alternatives you've considered

Supporting JsonIn on top of FlexBuffers was attempted and discarded as discussed on #50143.

Testing

CI, loaded and created games.

@akrieger akrieger requested a review from KorGgenT as a code owner September 7, 2021 04:53
@akrieger akrieger marked this pull request as draft September 7, 2021 04:53
@akrieger akrieger force-pushed the start_removing_jsonin branch from 466c237 to 6e14a2b Compare September 7, 2021 05:05
@actual-nh actual-nh added [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style labels Sep 7, 2021
@akrieger akrieger force-pushed the start_removing_jsonin branch 3 times, most recently from 53f19ab to 9d3432b Compare September 7, 2021 19:26
@akrieger akrieger marked this pull request as ready for review September 8, 2021 01:04
akrieger and others added 2 commits September 7, 2021 18:05
To allow for incremental migration to JsonValue type deserialization,
we can use the void_t detector pattern to enable one of two overloads
for JsonIn::read(), one which calls a member deserialize function that
takes JsonIn like before, and one which calls it with JsonValue. This
way we can directly migrate types to using a JsonValue derived
deserialize function without an intermediate state which has both old
and new function signatures present.
Most instances of deserialize instantly convert from JsonIn to the
object oriented interface, usually JsonObject. Using the improved
interface on JsonIn we can change the signatures on these to more
accurately reflect what they're doing. Also help get rid of JsonIn
which is not supported in the binary json refactor this unblocks.
@akrieger akrieger force-pushed the start_removing_jsonin branch from 9d3432b to 006c10b Compare September 8, 2021 01:25
@kevingranade kevingranade merged commit 46b015f into CleverRaven:master Sep 8, 2021
@akrieger akrieger deleted the start_removing_jsonin branch September 8, 2021 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style [JSON] Changes (can be) made in JSON
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants