Skip to content

Serialize case objects as literal strings #382

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

Merged
merged 18 commits into from
Apr 29, 2022
Merged

Serialize case objects as literal strings #382

merged 18 commits into from
Apr 29, 2022

Conversation

lihaoyi
Copy link
Member

@lihaoyi lihaoyi commented Mar 7, 2022

Now, case object Foo is now serialized as "pkg.path.Foo", rather than {"$type": "pkg.path.Foo"}. This simplifies the output, and makes serialized sealed trait/case object hierarchies look much more like simple enumerations when serialized. This harmonizes them with the simple serialization of Scala enums in #378.

case classes, even with zero parameters, are still serialized using the {"$type": "pkg.path.Foo"} encoding.

This is a breaking change; uPickle with this change continues to be able to read the old format, but older versions of uPickle will not be able to read the new format. This will need to go into uPickle 2.0.0, with appropriate migration support to smooth the transition

@lihaoyi lihaoyi requested review from htmldoug and jodersky March 7, 2022 01:29
@lihaoyi lihaoyi mentioned this pull request Mar 7, 2022
4 tasks
@lihaoyi
Copy link
Member Author

lihaoyi commented Mar 7, 2022

@jodersky upickle.MacroTests.commonCustomStructures.singleton fails on this PR on Scala 3. It seems that the Scala 3 macro implementation does not generate SingletonW/SingletonRs like the Scala 2 implementation does. Any idea how I can make it do that?

@lihaoyi lihaoyi changed the base branch from mapkeys to master April 29, 2022 03:51
@lihaoyi lihaoyi merged commit 92af781 into master Apr 29, 2022
@lefou lefou deleted the enums branch September 20, 2022 20:38
tdroxler added a commit to alephium/alephium that referenced this pull request Nov 21, 2022
Case objects don't seem to work anymore as enum due to:
com-lihaoyi/upickle#382
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.

1 participant