Weave 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 Laravel Package

webmozart/json

A robust PHP library for decoding, encoding, and validating JSON. It provides clear error messages with line and column details, JSON Schema validation, and convenient file handling via JsonFile, making JSON processing safer and easier in PHP applications.

Deep Wiki
Context7

webmozart/json is a robust PHP library for working with JSON documents. It provides JSON Schema validation (Draft 4) with exceptionally detailed error messages, making it easy to pinpoint exactly where a document fails to conform. Unlike basic json_decode, it offers precise control and clarity for debugging complex JSON structures.

Ideal for API validation and configuration parsing, the library simplifies error handling by collecting multiple validation errors and reporting them with precise JSON paths. This makes it a reliable choice for applications requiring strict data integrity and clear diagnostics.

  • JSON Schema Draft 4 compliant validation.
  • Precise error messages with exact JSON paths.
  • Collects multiple validation errors in one pass.
  • Validates PHP data structures (arrays/objects), not just strings.
  • Clean, extensible object-oriented API.
Frequently asked questions about Json
Is webmozart/json a Laravel package?
No. webmozart/json is a framework-agnostic low-level PHP JSON utility with no service provider, facade, or Laravel-specific integration surface. In Laravel it fits best as an isolated adapter at trust boundaries such as webhook ingestion, API payload parsing, configuration import, or event validation. You must create your own wrapper if you adopt it.
How do I install webmozart/json in a Laravel application?
Install it with Composer under the MIT license, but treat installation as a compatibility check rather than a routine require. The last release was in 2016, so verify PHP and Laravel version constraints and resolve the full dependency tree against your production lockfile. Laravel auto-discovery will not register anything because the package has no Laravel integration.
What is webmozart/json used for?
It provides robust JSON decoding and encoding, JSON Schema validation, JSON Pointer navigation, and clearer exceptions for malformed data. Typical uses are API payload validation, webhook ingestion, configuration import, and data interchange where schema-driven checks reduce risk. It should not become a pervasive replacement for native json_decode and json_encode.
Does webmozart/json support JSON Schema validation?
Yes, it validates JSON documents against JSON Schema and raises exceptions when data does not match. You must confirm which JSON Schema draft the package supports and whether your schemas rely on newer keywords. Schema validation improves correctness but does not replace authentication, rate limiting, payload size limits, or safe error mapping.
Is webmozart/json compatible with Laravel 10 or 11 and PHP 8?
There are no guarantees because the package has had no releases since 2016. Treat PHP 8.x and modern Laravel compatibility as a gated spike: test dependency resolution, deprecations, and exception behavior explicitly. A fork or vendor patch may be required, and you should pin the package and transitive dependencies before production use.
Should I use webmozart/json instead of Laravel Validator or native json_decode?
For most Laravel applications, native JSON handling plus Laravel Validator is sufficient. Use webmozart/json only when JSON Schema validation and stricter decode error handling materially reduce risk at a specific boundary. Keeping native handling as the default prevents a legacy utility from leaking across the codebase.
How should I integrate webmozart/json into a Laravel architecture?
Put it behind an application-owned interface such as JsonPayloadDecoder rather than calling it directly in controllers or domain models. Register it in a service provider only for the bounded contexts that need schema validation, and centralize schema paths and configuration. Inject the interface into application services so callers remain independent of the package.
What are the production risks of using webmozart/json?
The main risk is lifecycle, not API complexity: the package is effectively unmaintained, with no releases since 2016. Risks include PHP 8+ incompatibility, stale transitive dependencies, JSON Schema draft limitations, security exposure when parsing untrusted input, and unclear exception behavior. Perform dependency and CVE auditing, enforce payload size and depth limits, and document who owns any fork or patch path.
How do I test webmozart/json in a Laravel application?
Write contract tests against your adapter interface covering malformed JSON, schema mismatch, oversized payloads, and unsupported schema features. Compare behavior between the native implementation and the webmozart/json implementation before rolling it out. Test against your supported PHP and Laravel matrix and include static analysis in the spike.
What are the alternatives to webmozart/json for JSON Schema validation in Laravel?
Alternatives include Laravel Validator, native json_decode with JSON_THROW_ON_ERROR, and maintained modern JSON Schema libraries. Choose based on JSON Schema draft support, PHP and Laravel compatibility, maintenance activity, and security posture. Keep the adapter interface so you can replace webmozart/json without changing callers.
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.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo