to_json
compatibility with Python json
#102
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Updates
to_json
methods to returnstr
types so that they can be used with Pythonjson
Fixes #85
Changes
CompatiblePyType
, which validates incoming Python types to ensure they can be represented in the YCRDT.JsonBuilder
, which can append json from anyJsonBuildable
object to a string buffer.to_json
conversion.YArray
iterator method to return a PyIterator on eagerly evaluated array contents.Type Conversion Best Practices
In the past, we used
to_json
as a conversion to native Python types. In the future, we should use the direct constructor of the type we desire:Note that this is not a deep conversion.
YArray
Iterator UpdateThis addresses an unknown bug associated with the move behavior. While move works correctly when we pull the
Any
representation directly from the YrsArray
, the iterator from the raw pointer seems to move with the moved element.While this eager evaluation isn't ideal, it does match the expected behavior in
y-wasm
and fixes a significant bug with the move feature.