Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]: feat(bed-4728): Add jsonpointer package as core component for JSON sc… #805

Closed
wants to merge 1 commit into from

Commits on Aug 20, 2024

  1. feat(bed-4728): Add jsonpointer package as core component for JSON sc…

    …hema validation
    
    This commit introduces a new `jsonpointer` package that provides utilities for working with JSON Pointers as defined in RFC 6901. This package serves as a precursor and core component for our upcoming JSON schema validator package, laying the groundwork for efficient JSON traversal and manipulation.
    
    Key features:
    - Implements a `WalkJSON` function for traversing JSON-like structures
    - Supports map[string]any, []any, and uses reflection for other types
    - Provides a visitor pattern for custom handling of each element
    - Includes comprehensive documentation and usage examples
    - Offers extensibility for future enhancements, particularly for JSON schema validation
    
    The 'jsonpointer' package is designed with a clear goal in mind: to balance performance with flexibility. It provides fast paths for common JSON types while supporting complex nested structures. This balance is not just a feature, but a promise of efficiency and adaptability, crucial for implementing efficient JSON schema validation.
    
    Usage example:
    ```go
    data := map[string]any{
        "foo": []any{1, 2, 3},
        "bar": map[string]any{"baz": "qux"},
    }
    err := WalkJSON(data, func(elem any) error {
        fmt.Printf("Visited: %v\n", elem)
        return nil
    })
    ```
    
    REFERENCE: https://specterops.atlassian.net/browse/BED-4728
    neumachen committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    9a1dd22 View commit details
    Browse the repository at this point in the history