Skip to content

Drop node.toJSON() methods + reduce options on node.toJS()#664

Merged
eemeli merged 1 commit intomainfrom
simpler-tojs
Feb 14, 2026
Merged

Drop node.toJSON() methods + reduce options on node.toJS()#664
eemeli merged 1 commit intomainfrom
simpler-tojs

Conversation

@eemeli
Copy link
Copy Markdown
Owner

@eemeli eemeli commented Feb 14, 2026

Previously, nodes had both .toJS() and .toJSON() methods on each, and the .toJSON() ones were called internally from the .toJS() methods on both the Document as well as parent nodes -- and they didn't necessarily return JSON-compatible values. This was messy, and effectively a remnant of early API decisions that we can now reconsider.

This PR drops the .toJSON() methods from nodes, and simplifies the API for the .toJS() methods. I'm pretty sure that their options didn't actually get any use by anyone.

The top-level doc.toJS() still supports the same options as before, and a (simplified) top-level doc.toJSON() is also retained. Its casting of bigints to numbers is dropped.

The overall intent here is to reduce the amount of unnecessary work and indirection from parsing.

@eemeli eemeli added this to the v3 milestone Feb 14, 2026
@eemeli eemeli merged commit b1f4c46 into main Feb 14, 2026
21 of 24 checks passed
@eemeli eemeli deleted the simpler-tojs branch February 14, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant