ypy
ypy copied to clipboard
ydoc to json or some readable format
Is it possible with ypy to convert the ydoc contents to some readable format?
Hi @anujism, sorry for the delay. Are you trying to serialize the entire YDoc into something like a json representation?
hi @Waidhoferj no issues. The problem is that I have a ydoc and I am trying to make it searchable. To do that I want to extract the ydoc to some readable format so I can put it into elastic search and make the contents searchable.
We could probably make some iterator method over the root-level types. From there, you can always ask for their content one by one.
Agreed, something like
doc = Y.YDoc(1)
message = doc.get_text("message")
with d.begin_transaction() as txn:
message.extend("hello!")
# To get the contents of the doc
print(dict(doc.items()))
"""
{
"YText": { "message": YText("hello!") }
}
"""
yes, an iterator like that would be great!