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

Conversation

neumachen
Copy link
Contributor

…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:

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

Description

Describe your changes in detail

Motivation and Context

This PR addresses: [GitHub issue or Jira ticket number]

Why is this change required? What problem does it solve?

How Has This Been Tested?

Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc.

Screenshots (optional):

Types of changes

  • Chore (a change that does not modify the application functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Database Migrations

Checklist:

…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 neumachen added the ticketed Ticket has been created internally for tracking label Aug 20, 2024
@neumachen
Copy link
Contributor Author

neumachen commented Aug 22, 2024

Closing this to discuss the broader initiative of enhancing REST endpoints to validate requests and responses during testing.

@neumachen neumachen closed this Aug 22, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 22, 2024
@neumachen neumachen deleted the bed-4728 branch August 22, 2024 18:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ticketed Ticket has been created internally for tracking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant