Skip to content

Provides a presentation and transformation layer for complex data output

Notifications You must be signed in to change notification settings

jefersondaniel/fractal-output

Repository files navigation

Fractal Output

Build Status Version Pyversions

Provides a presentation and transformation layer for complex data output, the like found in RESTful APIs, and works really well with JSON. Think of this as a view layer for your JSON/YAML/etc. Based on https://fractal.thephpleague.com/

Documentation

Usage

Install:

$ pip install fractal_output

from fractal_output import Manager, Transformer, Item

class UserTransformer(Transformer):
    def transform(self, user):
        return {
            'id': user.id,
            'firstName': user.first_name
        }

user = YourUserClass()
transformer = UserTransformer()
item = Item(user, transformer)

manager = Manager()
manager.create_data(item).to_json()

About

Provides a presentation and transformation layer for complex data output

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages