Hi there,
I’m trying to do something a little bit nasty and dump an entire Y.Doc
to JSON/CBOR-like structures (ignoring history; just the latest state) so that a non-JavaScript (Rust) program can read some interesting parts of the documents and store some data about it in a tracking database.
My first approach to this was to iterate through doc.share.entries()
and dump each ‘shared type’ using a recursive helper function. It seemed to work OK.
However, it all fell over when I did this on a freshly-loaded document (as opposed to a document that I created and modified before dumping). From reading up about it, I think this is because I haven’t called doc.getMap("wombat")
and so on, to tell it what the shared types are.
Is it possible to dump the structure of the document without knowing which types are being used (or to find out what the types are?).
In my case I could just encode the types in the document itself as a map (…or hardcode it), but I suppose I was just surprised to see no way to do it.