hyperhyperspace / hyperhyperspace-core

A library to create p2p applications, using the browser as a full peer.
https://www.hyperhyperspace.org
MIT License
195 stars 12 forks source link

Dump and restore spaces to JSON #42

Open sbazerque opened 1 year ago

sbazerque commented 1 year ago

Dump and restore Hyper Hyper Space spaces to and from JSON literals.

So starting from the space's entry point, it should be possible to dump all its internal state into a single JSON-encoded string. The JSON should have enough metadata to recover the space without any additional information. This is fairly similar to what Context and specially LiteralContext do. It may be easier to go through a (memory-backed?) store to do the saving, and then using its contents to populate a LiteralContext to be included in the generated JSON. For loading it up back again, maybe it would be easier to load the contents of the LiteralContext back into a store (may be optional - if omitted we could just create a memory-backed one) than attempting to populate all the objects recursively automatically.

The generated JSON could be a first file format for importing / exporting spaces to and from files.