Skip to content

Change JSON serialization format - #32

Merged
phaller merged 1 commit into
phaller:mainfrom
jspenger:serialization-format
Apr 9, 2026
Merged

Change JSON serialization format#32
phaller merged 1 commit into
phaller:mainfrom
jspenger:serialization-format

Conversation

@jspenger

@jspenger jspenger commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

This PR implements a custom serialization format that does not depend on the uPickle default format.

  • Update tests to work with new serialization format
  • Bump uPickle version: "3.3.0" -> "4.4.3"
  • Replace the Packed spore representation with AST spore representation: now contains the value to be serialized whereas previously it was the serialized value
  • Remove Spore[ReadWriter[EmptyTuple]]
  • Add tests for serialization format

Other notes: I had to change the Scala Native version from 0.5.10 to 0.5.9 as the GitHub Actions runners otherwise (on 0.5.10) would frequently hang.

Here are some before/after examples:

Object builder:

Before:

{"$type":"spores.Packed.PackedObject","className":"spores.SporeBuilderTestsDefs$Predicate$"}

After:

{"tag":"Body","kind":0,"className":"spores.SporeBuilderTestsDefs$Predicate$"}

Class builder:

Before:

{"$type":"spores.Packed.PackedClass","className":"spores.SporeClassBuilderTestsDefs$Predicate"}

After:

{"tag":"Body","kind":1,"className":"spores.SporeClassBuilderTestsDefs$Predicate"}

Lambda builder:

Before:

{"$type":"spores.Packed.PackedLambda","className":"spores.jvm.SporeLambdaTestsDefs$Lambda$1"}

After:

{"tag":"Body","kind":2,"className":"spores.jvm.SporeLambdaTestsDefs$Lambda$1"}

With environment builder:

Before:

{"$type":"spores.Packed.PackedWithEnv","packed":{"$type":"spores.Packed.PackedObject","className":"spores.SporeBuilderTestsDefs$HigherLevelFilter$"},"packedEnv":{"$type":"spores.Packed.PackedEnv","env":"{\"$type\":\"spores.Packed.PackedObject\",\"className\":\"spores.SporeBuilderTestsDefs$Predicate$\"}","rw":{"$type":"spores.Packed.PackedObject","className":"spores.ReadWriters$SporeRW$"}}}

After (it is no longer necessary to escape by ""):

{"tag":"WithEnv","fun":{"tag":"Body","kind":0,"className":"spores.SporeBuilderTestsDefs$HigherLevelFilter$"},"env":{"tag":"Val","ev":{"tag":"Body","kind":0,"className":"spores.ReadWriters$SporeRW$"},"value":{"tag":"Body","kind":0,"className":"spores.SporeBuilderTestsDefs$Predicate$"}}}

- Update tests to work with new serialization format
- Bump uPickle version: "3.3.0" -> "4.4.3"
- Replace the `Packed` spore representation with AST spore representation: now contains the value to be serialized whereas previously it was the serialized value
- Remove Spore[ReadWriter[EmptyTuple]]
- Add tests for serialization format
@phaller
phaller self-requested a review April 8, 2026 13:48
@phaller
phaller merged commit aa5e349 into phaller:main Apr 9, 2026
6 checks passed
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