jlozanomaltos/json-reducer

An array size reducer (for JSON output purposes) using Models, Collections, Arrays
51 9
Install
composer require jlozanomaltos/json-reducer
Latest Version:v1.0.9
PHP:>=5.5.9
Older releases:5
License:MIT
Last Updated:Jan 12, 2017
Links: GitHub  ·  Packagist
Maintainer: jlozanomaltos

JsonReducer

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));
}

Related Packages

kenokokoro/v9-package-outbox

Outbox helper for Laravel/Lumen

9 0
danharper/laravel-jsonx

Add XML support to a JSON-speaking Laravel API with a single middleware via JSON...

60,423 18
seffeng/json-helper

PHP extension json helper

1,781 0
jfadich/json-property

Transform an object property into an enhanced array

458 3
soloslee/json-response

JSON-API response for Laravel

92 8

Version History

Version Released PHP Laravel License
v1.0.9 >=5.5.9 MIT
v1.0.7 >=5.5.9 MIT
v1.0.6 >=5.5.9 >=5.1.0 MIT
v1.0.5 >=5.5.9 5.1.* || 5.2.* MIT
v1.0.4 >=5.5.9 5.1.* || 5.2.* MIT