PHPackages                             arandu/laravel-safe-json-cast - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. arandu/laravel-safe-json-cast

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

arandu/laravel-safe-json-cast
=============================

A simple cast for Laravel Mui Admin Draft Js Plugin

v0.0.1(2y ago)0539MITPHPPHP ^8.0

Since Jan 14Pushed 2y ago1 watchersCompare

[ Source](https://github.com/AranduTech/laravel-safe-json-cast)[ Packagist](https://packagist.org/packages/arandu/laravel-safe-json-cast)[ RSS](/packages/arandu-laravel-safe-json-cast/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Laravel Safe Json Cast
======================

[](#laravel-safe-json-cast)

If you are using Laravel's native array/object cast, you may have noticed that it turns JS empty objects into empty arrays. This package provides an alternative to the native cast.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require arandu/laravel-safe-json-cast
```

Usage
-----

[](#usage)

```
use Arandu\LaravelSafeJsonCast\Json;

class User extends Model
{
    protected $casts = [
        'options' => Json::class,
    ];
}

$user = User::create([
    'name' => 'John Doe',
    'options' => [
        'foo' => 'bar',
    ],
]);

$user->options->foo; // bar
```

Best Practices
--------------

[](#best-practices)

It is advisable that you send casted fields as JSON strings from the frontend. This way you can avoid the problem of empty objects being converted to empty arrays. This package will handle JSON strings and convert them accordingly.

```
axios({
    method: 'post',
    url: '/api/users',
    data: {
        name: 'John Doe',
        options: JSON.stringify(userOptions),
    }
});
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

895d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/84a3afb785274d1c4712e7ed9fd924fe5dfd1f0c033e051f9d07d55df565920a?d=identicon)[obrunopolo](/maintainers/obrunopolo)

---

Top Contributors

[![obrunopolo](https://avatars.githubusercontent.com/u/47830258?v=4)](https://github.com/obrunopolo "obrunopolo (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/arandu-laravel-safe-json-cast/health.svg)

```
[![Health](https://phpackages.com/badges/arandu-laravel-safe-json-cast/health.svg)](https://phpackages.com/packages/arandu-laravel-safe-json-cast)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[illuminate/pipeline

The Illuminate Pipeline package.

9348.3M267](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10533.5M991](/packages/illuminate-pagination)[illuminate/redis

The Illuminate Redis package.

8314.4M362](/packages/illuminate-redis)[illuminate/cookie

The Illuminate Cookie package.

224.5M132](/packages/illuminate-cookie)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
