Skip to content

rodolfomg/JsonReducer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JsonReducer

This is a package based on the concept of Smaller Serialized Data, the implementation reduces the lenght of a JSON response as shown in the example.

Input (Array with multiple Dictionaries)

[{
  "id":1,
  "name":"Rodolfo",
  "username":"rodolfomg"
 },
 {
  "id":2,
  "name":"Pedro",
  "username":"pedro47"
}]

Output (Serialized Dictionary)

{
 "id": [1, 2],
 "name":["Rodolfo","Pedro"],
 "username":["rodolfomg","pedro47"]
}

Installation

Install package using pip

pip install JsonReducer

Usage

import JsonReducer
from .models import Users

def get_users(request):
    users = User.objects.all().values()
    users_list = list(users)
    return JsonResponse(JsonReduce.reduce(users_list), safe=False)
  

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages