Repository navigation
Added json gem 3.x support while keeping the 2.x wire format. - #133
Merged
Merged
Conversation
Signed-off-by: Hermann Mayer <hermann.mayer92@gmail.com>
Owner
|
Thank you! I really appreciate this. The change is well thought out and relevant. I have merged it into main. Expect a minor release later today. |
Contributor
Author
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
@evolve75 First of all, thank you for maintaining RubyTree, it is a great gem and we rely on it in several of our own applications.
What is it good for
The json gem 3.0 removed the
create_additionsmechanism and theJSON.create_idaccessor the JSON conversion of RubyTree was built on. With json 3.x installed,to_jsonraises becauseJSON.create_idis gone, andJSON.parse(..., create_additions: true)raises because the option no longer exists, so trees can neither be exported nor imported. The current~> 2.0constraint hides this by refusing json 3 at resolve time, which in turn blocks every application that already moved to json 3 (eg. Rails 8.1.4+) from installing RubyTree.This change makes RubyTree work with the json gem 2.x and 3.x alike. The serialized format stays byte-identical, so documents written by earlier versions remain readable, and a new
Tree::TreeNode.from_jsonrebuilds a tree on both majors.What I did
json_classtag from a gem-owned constant instead ofJSON.create_idfrom_jsonto rebuild a tree through the parser'son_loadcallbackjson_createas the hook for the json 2.xcreate_additionspath>= 2.21.2, < 4in the gemspec