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

Laravel Json Casted Laravel Package

novius/laravel-json-casted

Cast JSON columns in Laravel models with per-key casting. Define sub-key casts via a method or dedicated cast class; values are exposed as a Fluent object with proper types (e.g., Carbon dates). Supports PHP 8.2+ and Laravel 10+.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Feature Development: Enables structured JSON handling in Eloquent models, reducing manual parsing for nested JSON data (e.g., dates, booleans, arrays). Ideal for APIs, admin panels, or dynamic configurations where JSON flexibility is critical.
  • Roadmap Alignment: Supports initiatives requiring scalable JSON processing (e.g., analytics dashboards, multi-tenant feature flags) by abstracting casting logic into reusable components.
  • Build vs. Buy: Eliminates the need to reinvent JSON casting logic, saving engineering time. Best for projects where JSON flexibility is a requirement, not a differentiator.
  • Use Cases:
    • APIs: Automatically cast JSON payloads (e.g., {"metadata": {"published_at": "2023-01-01"}}) to native types (e.g., Carbon) for validation/processing.
    • Admin Panels: Simplify form handling by casting JSON attributes (e.g., {"settings": {"is_active": "true"}}) to booleans/collections.
    • Legacy Systems: Gradually adopt structured JSON casting with minimal refactoring.

When to Consider This Package

  • Adopt When:

    • Your Laravel app frequently handles nested JSON casting (e.g., dates, booleans, custom objects).
    • You want to avoid manual parsing of JSON attributes in models (e.g., json_decode($model->extras)->date).
    • Teams prioritize maintainability over micro-optimizations for JSON handling.
    • Your stack uses Laravel 10+ and PHP 8.2+ (minimal compatibility overhead).
  • Look Elsewhere If:

    • You need high-performance JSON processing (this package adds minor overhead for casting).
    • Your JSON schema is static/simple (native Laravel casts or manual handling may suffice).
    • You’re constrained by the AGPL-3.0 license (requires open-sourcing proprietary code).
    • You need advanced transformations (e.g., recursive casting, custom decoders) beyond basic type conversion.

How to Pitch It (Stakeholders)

For Executives:

"This package automates the conversion of messy JSON data into clean, usable formats—like turning a string date into a Carbon object—without writing repetitive code. It’s a 10-minute setup that saves hours of debugging and maintenance, especially for APIs or admin tools where JSON fields are common. Think of it as ‘auto-formatting’ for your database JSON blobs."

ROI:

  • Dev Velocity: Reduces boilerplate for JSON-heavy features.
  • Reliability: Catches type mismatches early (e.g., invalid dates) via Laravel’s casting system.
  • Scalability: Future-proofs JSON handling as the app grows.

For Engineering:

*"This solves the pain of manually casting nested JSON fields in Eloquent models. Instead of writing:

$model->extras = json_decode($model->extras, true);
$model->extras['date'] = Carbon::parse($model->extras['date']);

You define casts once (e.g., ['extras' => JsonCasted::class]), and Laravel handles the rest. It’s lightweight, integrates with IDE helpers, and works with Laravel’s existing casting ecosystem."*

Key Benefits:

  • Flexibility: Supports method-based or class-based casts for reusability.
  • IDE Support: Works with laravel-ide-helper for autocompletion.
  • Low Risk: Minimal abstraction; falls back to raw JSON if casting fails.
  • Future-Proof: Compatible with Laravel 10–13 and PHP 8.2+.
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.
nasirkhan/laravel-sharekit
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony