jlozanomaltos/json-reducer
Composer 安装命令:
composer require jlozanomaltos/json-reducer
包简介
An array size reducer (for JSON output purposes) using Models, Collections, Arrays
README 文档
README
What is it?
An array size reducer (for JSON output purposes) using Models, Collections, Arrays for Laravel/Lumen
It's basically an implementation of following: Smaller Serialized Data
Input example (Eloquent Model Array Visualization)
{ "data": [ { "id": 1, "name": "Jesús Emanuel", "lastname": "Lozano Maltos" }, { "id": 2, "name": "Gilberto", "lastname": "Reyes Barrera" } ] }
Output example (Array Visualization)
{ "data": { { "id":[1, 2], "name": ["Jesús Emanuel", "Gilberto"], "lastname": ["Lozano Maltos", "Reyes Barrera"] } } }
Installation
Require package using composer
composer require jlozanomaltos/json-reducer
Then just require the class (where you need it)
use JLozanoMaltos\JsonReducer\JsonReducer;
Example usage (laravel)
public function index() { $users = User::all(); return response()->json(JsonReducer::reduce($users)); }
统计信息
- 总下载量: 51
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-01-23