Package Data | |
---|---|
Maintainer Username: | seekerliu |
Maintainer Contact: | seekerliu@vip.qq.com (seekerliu) |
Package Create Date: | 2017-09-08 |
Package Last Update: | 2017-09-10 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-02-06 03:03:22 |
Package Statistics | |
---|---|
Total Downloads: | 967 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 9 |
Total Watchers: | 3 |
Total Forks: | 2 |
Total Open Issues: | 0 |
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"
json_encode
:$data = [
'a' => 0.1 + 0.7,
'b' => ['string1', 'string2'],
];
\YaJson::encode($data); //"{"a":0.8,"b":["string1","string2"]}"
json_encode
:$data = [
'a' => 0.1 + 0.7,
];
\YaJson::prepare($data); //['a'=>0.8]
composer require "seekerliu/laravel-another-json:dev-master"
Laravel 5.5
安装新包后会默认执行@php artisan package:discover
命令,所以可以不进行下面的操作。
ServiceProvider
及 Facade
:php artisan package:discover
php artisan vendor:publish
ServiceProvider
及 Facade
:'providers' => [
//...
Seekerliu\YaJson\ServiceProvider::class,
],
'aliases' => [
//...
'YaJson' => Seekerliu\YaJson\Facade::class,
],
php artisan vendor:publish --provider="Seekerliu\YaJson\ServiceProvider"
MIT