Serializer Enhancements
The serializer now understands dot-delimited paths that step through attributes, mappings, lists, and JSON encoded strings. This enables referencing deeply nested data in configuration files without custom post-processing.
Dot-Path Resolution
Paths such as text.results.0.id are resolved segment by segment:
textis looked up via attribute or mapping accessif the current value is a JSON string, it is decoded automatically
list segments accept numeric indices (
0)final segment (
id) returns the value when present
If at any point a segment is missing, the resolver returns None.
Array Limiting
When using the dictionary form of field definitions, limit restricts
the number of items returned from list results:
[serializers.search_serializer]
[serializers.search_serializer.fields]
id = "text.results.0.id"
results = { path = "text.results", limit = 1 }
With the Context7 search API this yields the first result alongside its identifier, allowing responses to be trimmed directly within the serializer configuration.
List Item Serialization
Lists extracted through path or method lookups can apply serializers
to each item with item_fields or item_serializer. This is useful
when each element requires its own field mapping:
[serializers.people]
[serializers.people.fields]
contacts = { path = "items", item_fields = { name = "name", age = "age" } }
# or reuse an existing serializer definition
enriched = { path = "items", item_serializer = { fields = { name = "name" } } }
Each element is mapped individually, producing a list of structured objects in the final output.
JSON Parsing
The parse_json parameter provides explicit control over JSON parsing
for fields containing JSON strings. This is useful when you need to
parse JSON data but want to control when and how it’s parsed:
[serializers.api_serializer]
[serializers.api_serializer.fields]
raw_text = "text"
parsed_data = { path = "text", parse_json = true }
first_item = { path = "text.items", parse_json = true, limit = 1 }
raw_textreturns the original JSON stringparsed_datareturns the parsed JSON objectfirst_itemparses JSON and extracts the first item from the array
The parse_json parameter is applied to the first segment of the path,
allowing subsequent path navigation through the parsed JSON structure.
Key Serialization
Dictionary and mapping keys that are not native JSON types (for example,
pandas.Timestamp) are automatically converted to ISO strings when
possible, falling back to str(key). This guarantees compatibility with
--json CLI output while preserving readable keys.