PHPackages                             rygilles/smart-json-reducer - 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. rygilles/smart-json-reducer

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

rygilles/smart-json-reducer
===========================

Helper to reduce JSON objects size applying truncates on string fields using weights

030.8kPHP

Since Nov 8Pushed 7y ago1 watchersCompare

[ Source](https://github.com/rygilles/smart-json-reducer)[ Packagist](https://packagist.org/packages/rygilles/smart-json-reducer)[ RSS](/packages/rygilles-smart-json-reducer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

smart-json-reducer
==================

[](#smart-json-reducer)

[![StyleCI](https://camo.githubusercontent.com/c8cb6706c2b5ca6521e27f972db4385a6e5c2997aa17c7e43e8c5841e95b61e9/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3135353138383530352f736869656c643f7374796c653d666c6174)](https://github.styleci.io/repos/155188505/shield?style=flat)[![Build Status](https://camo.githubusercontent.com/d7bf53c3a67a54d5d9634cfd57b03a58dcce7e150bd9591d2aa399f7db932c2b/68747470733a2f2f7472617669732d63692e6f72672f727967696c6c65732f736d6172742d6a736f6e2d726564756365722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/rygilles/smart-json-reducer)[![GitHub](https://camo.githubusercontent.com/908bff01b96c112b0ff03b93266d4742234fe17c141ebf9c7ad274f3ee091735/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f727967696c6c65732f736d6172742d6a736f6e2d726564756365722e737667)](https://camo.githubusercontent.com/908bff01b96c112b0ff03b93266d4742234fe17c141ebf9c7ad274f3ee091735/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f727967696c6c65732f736d6172742d6a736f6e2d726564756365722e737667)

Helper to reduce JSON objects size applying truncates on string fields using weights.

Requirements
============

[](#requirements)

- PHP &gt;= 5.5

Install
=======

[](#install)

Via Composer:

```
$ composer require rygilles/smart-json-reducer
```

Basic usage of `smart-json-reducer`
-----------------------------------

[](#basic-usage-of-smart-json-reducer)

**Important : The resulting JSON inner object values will be converted to array** (*Optimizations and fixes to come...*)

The JSON string is not modified if the `$maxSize` size (in bytes) is not reached.

`$weights` parameter must be an array with "dot style" path as key and weight as value (normalized automatically).

***The first version of this library doe not re-attribute gained space to others fields and final JSON string size will be significantly reduced.*** (*Optimizations and fixes to come...*)

```
