File: inflection.rst

package info (click to toggle)
python-marshmallow 3.26.1-0.4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,296 kB
  • sloc: python: 11,513; makefile: 11; sh: 8
file content (19 lines) | stat: -rw-r--r-- 619 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
*****************************
Inflection (camel-cased keys)
*****************************

HTTP APIs will often use camel-cased keys for their input and output representations. This example shows how you can use the
`Schema.on_bind_field <marshmallow.Schema.on_bind_field>` hook to automatically inflect keys.

.. literalinclude:: ../../examples/inflection_example.py
    :language: python

To run the example:

.. code-block:: shell-session

    $ uv run examples/inflection_example.py
    Loaded data:
    {'first_name': 'David', 'last_name': 'Bowie'}
    Dumped data:
    {'firstName': 'David', 'lastName': 'Bowie'}