Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Json Pointer

Json Pointer Laravel Package

ergebnis/json-pointer

RFC 6901 JSON Pointer abstraction for PHP. Create and convert reference tokens and pointers from plain strings, JSON string form, or URI fragment identifiers, with correct escaping and encoding. Install via Composer and use small, typed value objects.

View on GitHub
Deep Wiki
Context7

📃 Provides a composer package with an abstraction of a JSON pointer.

Frequently asked questions about Json Pointer
How do I install ergebnis/json-pointer in a Laravel project?
Run `composer require ergebnis/json-pointer` in your project root. The package has no Laravel dependencies and works with PHP 8.0+. No additional configuration is needed for basic usage.
Does this package support Laravel’s API resources or validation?
Yes. Use `ReferenceToken` to parse JSON pointers from request input (e.g., `Request::input('pointer')`) and integrate with Laravel’s `FormRequest` or `Validator` for path-based rules. Example: `Validator::make($data, ['pointer' => 'required|json_pointer'])`.
Can I use this for JSON:API or GraphQL field selection in Laravel?
Absolutely. The package’s `JsonPointer` class lets you dynamically traverse nested JSON (e.g., `/data/attributes/address`). Pair it with Laravel’s API resources to include/exclude fields based on pointers.
What Laravel versions and PHP versions are supported?
The package works with Laravel 9+ (PHP 8.0+) and Laravel 10+ (PHP 8.1+). For Laravel 9, use version `v3.4.0+` of the package. Always check the [Packagist page](https://packagist.org/packages/ergebnis/json-pointer) for updates.
How do I handle Unicode characters (e.g., emojis) in JSON pointers?
The package automatically escapes Unicode characters (e.g., `😆` becomes `~1%F0%9F%98%86` in URI fragments or `~😆` in JSON strings). Use `ReferenceToken::fromString('path/😆')` to create tokens with full Unicode support.
Is there a way to add custom JSON pointer validation in Laravel?
Yes. Extend Laravel’s `Validator` with a custom rule. Example: Register a `JsonPointerRule` in a service provider and use it like `Validator::extend('json_pointer', function ($attribute, $value, $parameters) { return ReferenceToken::fromString($value)->isValid(); })`.
Can I use this with Eloquent or Laravel Scout for nested JSON queries?
Yes. Add a query builder macro (e.g., `whereJsonPointer()`) to Eloquent in your `AppServiceProvider` to filter JSON columns. For Scout, use pointers to index nested fields in your searchable array.
What are the alternatives to ergebnis/json-pointer for Laravel?
Alternatives include manual string manipulation with `json_decode()` or packages like `spatie/json-schema`. However, this package offers strict RFC 6901 compliance, type safety, and built-in conversions between string, JSON, and URI formats—ideal for production APIs.
How do I test JSON pointer logic in Laravel unit tests?
Mock `ReferenceToken` instances for predictable behavior. Example: `ReferenceToken::fromJsonString('foo~1bar')->toString()` should return `'foo/bar'`. Use PHPUnit assertions to validate pointer conversions and edge cases (e.g., malformed input).
Does this package work with Laravel’s caching or file storage?
Yes. Store JSON pointers as strings in caches (e.g., Redis) or files. Convert between formats (e.g., `toJsonString()` for caching) to ensure compatibility. The package’s immutable value objects prevent unintended modifications.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai