dictutils.ops.projectΒΆ
- dictutils.ops.project(d, paths)[source]ΒΆ
Extract only specified paths from nested object.
- Parameters:
- Return type:
- Returns:
New object containing only the specified paths
Example
>>> import json >>> data = {"user": {"name": "Alice", "age": 30, "email": "alice@example.com"}} >>> result = project(data, ["user.name", "user.email"]) >>> print(json.dumps(result, indent=4)) { "user": { "name": "Alice", "email": "alice@example.com" } }