Skip to main content

The easiest way to switch case of prop in return of your functions

Project description

CASE SWITCHER

This module provides a very useful feature that will simplify communication between developers of Python RestAPI and other API libraries and frontend developers.

The provided function makes it possible to develop the main function code on the usual code case, but, called by default, it converts the fields of the object returned by the main function from snake_case to camelCase

Installing

pip install object_case_switcher

Examples

Simple use

from object_case_switcher import transform_structure

@transform_structure(_async=False)
def some_function():
    return {
        "some_property": 42,
    }

print(some_function())

# >>> '{"someProperty": 42}'

Recursive case

You can return an object with any level of nesting from a function

from object_case_switcher import transform_structure

@transform_structure(_async=False)
def some_function():
    return {
        "some_property": 42,
        "some_other_property": {
            "a": 52,
            "b": [
                {
                    "title_name": "John",
                },
                {
                    "title_name": "Dow",
                },
            ]
        },
    }

print(some_function())

Output

{
    "someProperty": 42,
    "someOtherProperty": {
        "a": 52,
        "b": [
            {"titleName": "John"},
            {"titleName": "Dow"},
        ]
    }
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

object_case_switcher-0.0.28.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distribution

object_case_switcher-0.0.28-py3-none-any.whl (6.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page