Skip to content

CamelCaseJsonResponse class

The CamelCaseJsonResponse modifies JsonResponse behaviour by attempting to camelCase JSON fields on the response. This provides an effective mechanism to generate camelCase structures from snake_case sources, such as FieldMapper objects or other commonly used Python structures.

Example:

    # our response data
    data = {
        "first_name": "John",
        "last_name": "Connor",
    }

    # build response object
    response = CamelCaseJsonResponse(data)

    # output: '{"success":true,"data":{"firstName":"John", "lastName":"Connor"}'
    print(response.get_data(True))