2017 © Pedro Peláez
 

library json-crunch

Optimizes JSON responses by minimizing duplication and improving compressibility.

image

gromnan/json-crunch

Optimizes JSON responses by minimizing duplication and improving compressibility.

  • Saturday, July 14, 2018
  • by GromNaN
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

PHP implementation of the node module graphql-crunch., (*1)

Optimizes JSON responses by minimizing duplication and improving compressibility., (*2)

Installation

composer require gromnan/json-crunch

How does it work?

We flatten the object hierarchy into an array using a post-order traversal of the object graph. As we traverse we efficiently check if we've come across a value before, including arrays and objects, and replace it with a reference to it's earlier occurence if we've seen it. Values are only ever present in the array once., (*3)

Usage

use function GromNaN\JsonCrunch\crunch;

$data = json_decode('{"a":["a","b","a"],"b":["a","b","a"]}');

$crunched = crunch($data);

echo json_encode($data, JSON_PRETTY_PRINT);

Result:, (*4)

[
    "a",
    "b",
    [0,1,0],
    {"a":2,"b":2}
]

Command-line

bin/crunch-json <file>

The Versions

14/07 2018

dev-master

9999999-dev

Optimizes JSON responses by minimizing duplication and improving compressibility.

  Sources   Download

MIT

by Jérôme Tamarelle

14/07 2018

v1.0.0

1.0.0.0

Optimizes JSON responses by minimizing duplication and improving compressibility.

  Sources   Download

MIT

by Jérôme Tamarelle