PHPackages                             seekerliu/laravel-another-json - 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. seekerliu/laravel-another-json

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

seekerliu/laravel-another-json
==============================

Yet Another JSON encoder for Laravel.

99762PHP

Since Sep 10Pushed 8y ago2 watchersCompare

[ Source](https://github.com/seekerliu/laravel-another-json)[ Packagist](https://packagist.org/packages/seekerliu/laravel-another-json)[ RSS](/packages/seekerliu-laravel-another-json/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

laravel-anothor-json
====================

[](#laravel-anothor-json)

Yet Another JSON Encoder For Laravel.
用于修复 PHP7.1、7.2beta 中 json\_encode() 处理 float/double 型数值时溢出的问题.

> 感谢博主提供的思路

示例
--

[](#示例)

```
>>> $a = 0.1 + 0.7
=> 0.8
>>> printf('%.20f', $a)
=> 0.79999999999999993339
>>> json_encode($a)
=> "0.7999999999999999"
>>> \YaJson::encode($a)
=> "0.8"
```

用法
--

[](#用法)

1. 修复精度并进行 `json_encode` ：

```
$data = [
    'a' => 0.1 + 0.7,
    'b' => ['string1', 'string2'],
];

\YaJson::encode($data);    //"{"a":0.8,"b":["string1","string2"]}"
```

2. 只获取修复后的数据，不进行 `json_encode` ：

```
$data = [
    'a' => 0.1 + 0.7,
];

\YaJson::prepare($data);   //['a'=>0.8]
```

安装
--

[](#安装)

1. 安装包文件

```
composer require "seekerliu/laravel-another-json:dev-master"
```

配置
--

[](#配置)

### Laravel 5.5

[](#laravel-55)

> `Laravel 5.5` 安装新包后会默认执行 `@php artisan package:discover` 命令，所以可以不进行下面的操作。

1. 注册 `ServiceProvider` 及 `Facade`:

```
php artisan package:discover
```

2. 如需修改默认循环深度、精度位数，则创建配置文件：

```
php artisan vendor:publish
```

### Laravel 5.4 及以下

[](#laravel-54-及以下)

1. 注册 `ServiceProvider` 及 `Facade`:

```
'providers' => [
    //...

    Seekerliu\YaJson\ServiceProvider::class,
],

'aliases' => [
    //...

    'YaJson' => Seekerliu\YaJson\Facade::class,
],
```

2. 如需修改默认循环深度、精度位数，则创建配置文件：

```
php artisan vendor:publish --provider="Seekerliu\YaJson\ServiceProvider"
```

License
-------

[](#license)

MIT

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.1% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8a75a733b92b7487ba3cb6e4d629a9df143f2865afd262e00f017de8d006621e?d=identicon)[seekerliu](/maintainers/seekerliu)

---

Top Contributors

[![seekerliu](https://avatars.githubusercontent.com/u/8923281?v=4)](https://github.com/seekerliu "seekerliu (16 commits)")[![justcodingnobb](https://avatars.githubusercontent.com/u/16287171?v=4)](https://github.com/justcodingnobb "justcodingnobb (1 commits)")

### Embed Badge

![Health badge](/badges/seekerliu-laravel-another-json/health.svg)

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

###  Alternatives

[baldwin/magento2-module-url-data-integrity-checker

Magento 2 module which can find potential url related problems in your catalog data

281773.3k](/packages/baldwin-magento2-module-url-data-integrity-checker)[johnbillion/wp-crontrol

Take control of the cron events on your WordPress website or WooCommerce store

22381.4k1](/packages/johnbillion-wp-crontrol)[ademarre/binary-to-text-php

Collection of binary-to-text encoding utilities for PHP. Includes Base32 support and much more.

40165.8k](/packages/ademarre-binary-to-text-php)

PHPackages © 2026

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