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 Decoder

Json Decoder Laravel Package

karriere/json-decoder

JsonDecoder maps JSON into typed PHP objects, handling nested objects, arrays, scalar casting, required fields, and custom decoders. It turns API responses and config files into predictable, IDE-friendly classes for safer, cleaner PHP code.

View on GitHub
Deep Wiki
Context7

JsonDecoder implementation that allows you to convert your JSON data into PHP class objects.

Frequently asked questions about Json Decoder
How do I install karriere/json-decoder in a Laravel project?
Run composer require karriere/json-decoder, then instantiate the decoder and call decode($json, MyDto::class). There are no migrations, middleware, or environment variables to configure. The only prerequisites are PHP 8.2 or newer and PSR-4 autoloading for the namespace that holds your DTO classes.
Does karriere/json-decoder ship with a Laravel service provider or facade?
No. It is a framework-agnostic, plain-PHP hydration library with no Illuminate dependency, so there is no config file, facade, or publishable asset. If you want dependency injection, bind the decoder as a container singleton yourself and resolve it in your services. This is intentional: the package is meant to sit behind an anti-corruption layer rather than integrate with Laravel internals.
Which PHP versions does karriere/json-decoder 5.1.0 support?
Version 5.1.0 supports PHP 8.2 through 8.5; it added 8.5 and removed 8.0 and 8.1. Dropping runtimes in a minor release is a semver violation, so pin to ^5.1 deliberately or to an exact minor rather than using a loose constraint. Any app server, queue worker, or CI runner still on PHP 8.1 will fail Composer resolution against this version, in which case stay on the last 5.0.x release.
Can karriere/json-decoder map nested objects and arrays of objects?
Yes. Mapping is driven by docblocks or attributes and handles nested objects, arrays of objects, scalar casting, and required fields. That makes it practical for real API payloads with several levels of structure. Edge cases such as nullable nested objects, unknown keys, enums, and readonly or union types should still be verified empirically against your own payloads before broad rollout.
Can I use karriere/json-decoder to hydrate Eloquent models or validate requests?
No. It is a DTO hydration library, not an Eloquent mapper or a validation layer, and it has no awareness of database models. The intended pattern is to decode JSON into plain typed classes and pass those objects into domain services. Keep using form requests and Laravel's validator for request input validation.
What happens with missing keys, extra keys, nulls, or type mismatches in karriere/json-decoder?
Required fields are enforced, so a missing one is an error rather than a silently empty object. Behaviour for optional missing keys, extra keys, explicit nulls, and type mismatches can be an exception, a silent null, or coercion depending on the definition, so test each case against your payloads. The 5.1.0 release notes claim no hydration changes, but that is not proof of no behaviour change, so confirm through the actual diff.
Is karriere/json-decoder a good fit for decoding third-party API responses and webhook payloads in Laravel?
Yes, this is its strongest use case. Decode third-party API responses, webhook bodies, queue message payloads, or config files into predictable, IDE-friendly DTOs before they reach your domain services. That gives you a clean anti-corruption layer with typed properties instead of raw arrays scattered through the codebase.
What license does karriere/json-decoder use?
The package metadata reports NOASSERTION, even though the repository appears to carry an MIT-style license file that is not declared in composer.json. Treat it as all rights reserved until your legal team confirms, and ideally get written clarification from the maintainer. This is the first blocker to clear before production use, and version 5.1.0 does not change it.
How does karriere/json-decoder compare to spatie/laravel-data or symfony/serializer?
spatie/laravel-data is Laravel-native with built-in validation and a large community, while symfony/serializer is foundation-backed and widely adopted. karriere/json-decoder is lighter and framework-agnostic, but it has a small contributor pool, roughly 140 stars, no registered dependents, and a low opportunity score that signals limited ecosystem momentum. All three have their own PHP version floor cadence, so that is not a differentiator either way.
Is karriere/json-decoder actively maintained?
Adding PHP 8.5 support in 5.1.0 shows the maintainer is tracking the PHP release cycle and is not dormant, which partially offsets bus-factor concerns. The contributor pool is still small, with no foundation or commercial backing, so avoid assuming rapid responses. Pin your constraint, let Renovate or Dependabot surface bumps for review instead of auto-merging, and treat the minor-version PHP floor drop as a signal to keep versions deliberate.
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