Interactive Traversal
Using traverseJsonTree for interactive node discovery and modification
Interactive Tree Traversal
This example demonstrates how to use the traverseJsonTree generator function to interactively traverse and modify JSON trees.
Basic Traversal
The simplest way to use traverseJsonTree is to iterate over all nodes in the tree:
Filtering Nodes by Type
You can filter nodes by type to focus on specific components:
Modifying Nodes During Traversal
One of the most powerful features of traverseJsonTree is the ability to modify nodes as you traverse them:
Skipping Children
You can skip traversing the children of certain nodes using the context.skipChildren() method:
Using Different Traversal Orders
traverseJsonTree supports three traversal orders:
Cloning vs. Direct Modification
By default, traverseJsonTree works directly on the input object (clone: false). If you want to preserve the original object, use the clone option:
Practical Example: Form Validation
This example shows how to use traverseJsonTree to add validation to a form:
This example demonstrates how traverseJsonTree enables powerful runtime modifications and inspections of your JSON UI definitions.